CMonikerFile Class
Represents a stream of data ( IStream) named by an IMoniker.
class CMonikerFile : public COleStreamFile
Name | Description |
---|---|
CMonikerFile::CMonikerFile | Constructs a CMonikerFile object. |
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. |
Name | Description |
---|---|
CMonikerFile::CreateBindContext | Obtains the bind context or creates a default initialized bind context. |
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 IStream
s named by IMoniker
s 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.
CMonikerFile
Header: afxole.h
Call this function to detach and release the stream and to release the moniker.
virtual void Close();
Can be called on unopened or already closed streams.
Constructs a CMonikerFile
object.
CMonikerFile();
Call this function to create a default initialized bind context.
IBindCtx* CreateBindContext(CFileException* pError);
pError
A pointer to a file exception. In the event of an error, it will be set to the cause.
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.
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.
Call this function to close the stream.
BOOL Detach(CFileException* pError = NULL);
pError
A pointer to a file exception. In the event of an error, it will be set to the cause.
Nonzero if successful; otherwise 0.
Call this function to retrieve a pointer to the current moniker.
IMoniker* GetMoniker() const;
A pointer to the current moniker interface ( IMoniker).
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.
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);
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.
Nonzero if successful; otherwise 0.
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"));
COleStreamFile Class
Hierarchy Chart
CAsyncMonikerFile Class