IPersistStorage::Save
Saves an
object, and any nested objects that it contains, into the specified storage.
The object is placed in NoScribble mode, and it must not write to the specified
storage until it receives a call to its IPersistStorage::SaveCompleted
HRESULT Save(
IStorage *pStgSave, |
//Pointer
to storage object |
BOOL fSameAsLoad |
//Indicates
whether the specified storage object is the current one |
); |
|
Parameters
pStgSave
[in]IStorage
pointer to the storage into which the object is to be saved.
fSameAsLoad
[in]Indicates
whether the specified storage is the current one, which was passed to the
object by one of the following calls:
IPersistStorage::InitNew when it was created.
IPersistStorage::Load when it was loaded.
IPersistStorage::SaveCompleted when 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.
Return Values
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::SaveCompleted
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::Save method, the OleSave
This method
does not call the IStorage::Commit
Notes to Callers
Rather than
calling IPersistStorage::Save directly, you typically call the OleSave
1. Call the WriteClassStg function to write the class
identifier for the object to the storage.
2. Call the IPersistStorage::Save method.
3. If needed, call the IStorage::Commit method on the storage
object.
Then, a
container application performs any other operations necessary to complete the
save and calls the SaveCompleted method for each object.
If an
embedded object passes the IPersistStorage::Save method to its nested
objects, it must receive a call to its IPersistStorage::SaveCompleted
See Also