Important: |
---|
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist. |
This method saves an object and any nested objects that it contains into the specified storage. The object is placed in NoScribble mode and must not write to the specified storage until it receives a call to its IPersistStorage::SaveCompletedmethod.
Syntax
HRESULT Save( IStorage* pStgSave, BOOL fSameAsLoad ); |
Parameters
- pStgSave
-
[in] IStoragepointer to the storage into which the object is to be saved.
- fSameAsLoad
-
[in] Boolean value that indicates whether the specified storage is the current one, which was passed to the object by one of the following calls:
-
IPersistStorage::InitNewwhen it was created.
-
IPersistStorage::Loadwhen it was loaded.
-
IPersistStorage::SaveCompletedwhen it was saved to a storage
different from its current storage.
This parameter is set to FALSE when performing a Save As or Save A Copy To operation or when performing a full save. In the latter case, this method saves to a temporary file, deletes the original file, and renames the temporary file.
This parameter is set to TRUE to perform a full save in a low-memory situation or to perform a fast incremental save in which only the dirty components are saved.
-
IPersistStorage::InitNewwhen it was created.
Return Value
The following table shows the return values for this method.
Value | Description |
---|---|
S_OK |
The object was successfully saved. |
STG_E_MEDIUMFULL |
The object was not saved because of a lack of space on the disk. |
E_FAIL |
The object could not be saved due to errors other than a lack of disk space. |
Remarks
This method saves an object, and any nested objects it contains, into the specified storage. It also places the object into NoScribble mode. Thus, the object cannot write to its storage until a subsequent call to the IPersistStorage::SaveCompletedmethod returns the object to Normal mode.
If the storage object is the same as the one it was loaded or created from, the save operation may be able to write incremental changes to the storage object. Otherwise, a full save must be done.
This method recursively calls the IPersistStorage::Savemethod, the OleSavefunction, or the IStorage::CopyTomethod to save its nested objects.
This method does not call the IStorage::Commitmethod. Nor does it write the CLSID to the storage object. Both of these tasks are the responsibilities of the caller.
To determine whether the platform supports this interface, see Determining Supported COM APIs.
Notes to Callers
Rather than calling IPersistStorage::Savedirectly, you typically call the OleSavehelper function that performs the following steps:
- Call the
WriteClassStgfunction to write the class identifier for the
object to the storage.
- Call the
IPersistStorage::Savemethod.
- If needed, call the
IStorage::Commitmethod on the storage object.
Then, a container application performs any other operations necessary to complete the save and calls the SaveCompletedmethod for each object.
If an embedded object passes the IPersistStorage::Savemethod to its nested objects, it must receive a call to its IPersistStorage::SaveCompletedmethod before calling this method for its nested objects.
Requirements
Header | objidl.h, objidl.idl |
Library | ole32.lib, uuid.lib |
Windows Embedded CE | Windows CE 2.0 and later |
Windows Mobile | Windows Mobile Version 5.0 and later |