IPersistFile::Load
A version of this page is also available for
4/8/2010
This method opens the specified file and initializes an object from the file contents.
Syntax
HRESULT Load(
LPCOLESTR pszFileName,
DWORD dwMode
);
Parameters
- pszFileName
[in] Points to a zero-terminated string containing the absolute path of the file to open.
dwMode
[in] Specifies some combination of the values from the STGM enumeration to indicate the access mode to use when opening the file.IPersistFile::Load can treat this value as a suggestion, adding more restrictive permissions if necessary.
If dwMode is zero, the implementation should open the file using whatever default permissions are used when a user opens the file.
Return Value
- S_OK
The object was successfully loaded.
- E_OUTOFMEMORY
The object could not be loaded due to a lack of memory.
- E_FAIL
The object could not be loaded for some reason other than a lack of memory.
IPersistFile::Load STG_E_* error codes can also be returned.
Remarks
IPersistFile::Load loads the object from the specified file. This method is for initialization only and does not show the object to the user. It is not equivalent to what occurs when an user selects the File Open command.
To determine whether the platform supports this interface, see Determining Supported COM APIs.
Notes to Callers
The BindToObject method in file monikers calls this method to load an object during a moniker binding operation (when a linked object is run). Typically, applications do not call this method directly.
Notes to Implementers
Because the information needed to open a file varies greatly from one application to another, the object on which this method is implemented must also open the file specified by the pszFileName parameter.
This differs from the IPersistStorage::Load and IPersistStream::Load, in which the caller opens the storage or stream and then passes an open storage or stream pointer to the loaded object.
For an application that typically uses OLE compound files, your IPersistFile::Load implementation can simply call the StgOpenStorage function to open the storage object in the specified file. Then, you can proceed with standard initialization. Applications that do not use storage objects can perform standard file-opening procedures.
When the object has been loaded, your implementation should register the object in the Running Object Table (see IRunningObjectTable::Register).
Requirements
Header | objidl.h, objidl.idl |
Library | ole32.lib, uuid.lib |
Windows Embedded CE | Windows CE 3.0 and later |
Windows Mobile | Windows Mobile Version 5.0 and later |