IPersistFile::Load

Opens the specified file and initializes an object from the file contents.

HRESULT Load(

LPCOLESTR pszFileName,
//Pointer to absolute path of the file to open
DWORD dwMode
//Specifies the access mode from the STGM enumeration
);

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. The IPersistFile::Load method 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 Values

S_OK

The object was successfully loaded.

E_NOMEMORY

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.

Comments

This method loads the object from the specified file. This method is for initialization only and does not show the object to the end user; it is not equivalent to the end user selecting the File Open command.

Notes to Callers

The BindToObject method in file monikers calls this method to load an object during a moniker binding operation, that is, when the linked object is run.

Typically, applications do not call this method directly.

Notes to Implementors

Because the information needed to open a file varies greatly from one application to another, the object that implements this method must also open the file specified by the pszFileName parameter. Note that 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.

If your application normally uses the OLE-provided compound files, then your IPersistFile::Load implementation can simply call the StgOpenStorage helper API function to open the storage object in the specified file. Then, you can proceed with the normal document initialization. Applications that do not use storage objects can perform their normal file opening procedures.

When the document has been loaded, your implementation should register the document object in the Running Object Table (see IRunningObjectTable::Register).

See Also

IRunningObjectTable::Register, StgOpenStorage

Software for developers
Delphi Components
.Net Components
Software for Android Developers
More information resources
MegaDetailed.Net
Unix Manual Pages
Delphi Examples
Databases for Amazon shops developers
Amazon Categories Database
Browse Nodes Database