IStorage::DestroyElement method

The DestroyElement method removes the specified storage or stream from this storage object.


HRESULT DestroyElement(
  const OLECHAR *pwcsName



A pointer to a wide character null-terminated Unicode string that contains the name of the storage or stream to be removed.

Return value

This method can return one of these values.


The DestroyElement method deletes a substorage or stream from the current storage object. After a successful call to DestroyElement, any open instance of the destroyed element from the parent storage becomes invalid.

If a storage object is opened in the transacted mode, destruction of an element requires that the call to DestroyElement be followed by a call to IStorage::Commit.

Note  The DestroyElement method does not shrink the directory stream. It only marks the deleted directory entry as invalid. Invalid entries are reused when creating a new storage or stream.

For content streams, the deleted stream sectors are marked as free. If the free sectors are at the end of the file, the document file should shrink. To compact a document file, call IStorage::CopyTo on the root storage object and copy to a new storage object.



Minimum supported client Windows 2000 Professional [desktop apps | UWP apps]
Minimum supported server Windows 2000 Server [desktop apps | UWP apps]
Target Platform Windows
Header objidl.h
Library Uuid.lib
DLL Ole32.dll

See also

IStorage - Compound File Implementation