Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Represents a stream of data ( IStream) named by an IMoniker.
Syntax
class CMonikerFile : public COleStreamFile
Members
Public Constructors
| Name | Description |
|---|---|
| CMonikerFile::CMonikerFile | Constructs a CMonikerFile object. |
Public Methods
| Name | Description |
|---|---|
| CMonikerFile::Close | Detaches and releases the stream and releases the moniker. |
| CMonikerFile::Detach | Detaches the IMoniker from this CMonikerFile object. |
| CMonikerFile::GetMoniker | Returns the current moniker. |
| CMonikerFile::Open | Opens the specified file to obtain a stream. |
Protected Methods
| Name | Description |
|---|---|
| CMonikerFile::CreateBindContext | Obtains the bind context or creates a default initialized bind context. |
Remarks
A moniker contains information much like a pathname to a file. If you have a pointer to a moniker object's IMoniker interface, you can get access to the identified file without having any other specific information about where the file is actually located.
Derived from COleStreamFile, CMonikerFile takes a moniker or a string representation it can make into a moniker and binds to the stream for which the moniker is a name. You can then read and write to that stream. The real purpose of CMonikerFile is to provide simple access to IStreams named by IMonikers so that you do not have to bind to a stream yourself, yet have CFile functionality to the stream.
CMonikerFile cannot be used to bind to anything other than a stream. If you want to bind to storage or an object, you must use the IMoniker interface directly.
For more information on streams and monikers, see COleStreamFile in the MFC Reference and IStream and IMoniker in the Windows SDK.
Inheritance Hierarchy
CMonikerFile
Requirements
Header: afxole.h
CMonikerFile::Close
Call this function to detach and release the stream and to release the moniker.
virtual void Close();
Remarks
Can be called on unopened or already closed streams.
CMonikerFile::CMonikerFile
Constructs a CMonikerFile object.
CMonikerFile();
CMonikerFile::CreateBindContext
Call this function to create a default initialized bind context.
IBindCtx* CreateBindContext(CFileException* pError);
Parameters
pError
A pointer to a file exception. In the event of an error, it will be set to the cause.
Return Value
A pointer to the bind context IBindCtx to bind with if successful; otherwise NULL. If the instance was opened with an IBindHost interface, the bind context is retrieved from the IBindHost. If there is no IBindHost interface or the interface fails to return a bind context, a bind context is created. For a description of the IBindHost interface, see the Windows SDK.
Remarks
A bind context is an object that stores information about a particular moniker binding operation. You can override this function to provide a custom bind context.
CMonikerFile::Detach
Call this function to close the stream.
BOOL Detach(CFileException* pError = NULL);
Parameters
pError
A pointer to a file exception. In the event of an error, it will be set to the cause.
Return Value
Nonzero if successful; otherwise 0.
CMonikerFile::GetMoniker
Call this function to retrieve a pointer to the current moniker.
IMoniker* GetMoniker() const;
Return Value
A pointer to the current moniker interface ( IMoniker).
Remarks
Since CMonikerFile is not an interface, the pointer returned does not increment the reference count (through AddRef), and the moniker is released when the CMonikerFile object is released. If you want to hold onto the moniker or release it yourself, you must AddRef it.
CMonikerFile::Open
Call this member function to open a file or moniker object.
virtual BOOL Open(
LPCTSTR lpszURL,
CFileException* pError = NULL);
virtual BOOL Open(
IMoniker* pMoniker,
CFileException* pError = NULL);
Parameters
lpszURL
A URL or filename of the file to be opened.
pError
A pointer to a file exception. In the event of an error, it will be set to the cause.
pMoniker
A pointer to the moniker interface IMoniker to be used to obtain a stream.
Return Value
Nonzero if successful; otherwise 0.
Remarks
The lpszURL parameter cannot be used on a Macintosh. Only the pMoniker form of Open can be used on a Macintosh.
You can use a URL or a filename for the lpszURL parameter. For example:
CMyMoniker* pMyMoniker = new CMyMoniker();
pMyMoniker->Open(_T("http://www.microsoft.com"));
- or -
CMyMoniker* pMyMoniker = new CMyMoniker();
pMyMoniker->Open(_T("file:c:\\mydata.dat"));
See also
COleStreamFile Class
Hierarchy Chart
CAsyncMonikerFile Class