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 checks an object for changes since it was last saved to its current file.
Syntax
HRESULT IsDirty(void); |
Parameters
None.
Return Value
- S_OK
-
The object has changed since it was last saved.
- S_FALSE
-
The object has not changed since the last save.
Remarks
This method checks whether an object has changed since it was last saved. Call it to determine whether an object should be saved before closing it. The dirty flag for an object is conditionally cleared in the IPersistFile::Savemethod.
To determine whether the platform supports this interface, see Determining Supported COM APIs.
Notes to Callers
OLE does not call IPersistFile::IsDirty. Applications would not call it unless they are also saving an object to a file.
You should treat any error return codes as an indication that the object has changed. Unless this method explicitly returns S_FALSE, assume that the object must be saved.
Notes to Implementers
An object with no contained objects simply checks its dirty flag to return the appropriate result.
A container with one or more contained objects must maintain an internal dirty flag that is set when any of its contained objects has changed since it was last saved.
To do this, the container should maintain an advise sink by implementing the IAdviseSinkinterface.
Then, the container can register each link or embedding for data change notifications with a call to IDataObject::DAdvise.
Then, the container can set its internal dirty flag when it receives an IAdviseSink::OnDataChangenotification.
If the container does not register for data change notifications, the IPersistFile::IsDirtyimplementation would call IPersistStorage::IsDirtyfor each of its contained objects to determine whether they have changed.
The container can clear its dirty flag whenever it is saved, as long as the file to which the object is saved is the current working file after the save. Therefore, the dirty flag would be cleared after a successful Save or Save As operation, but not after a Save A Copy As operation.
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 |