Desktop Functions:

   Smart Device Functions:

Show Recent Changes
Subscribe (RSS)
Misc. Pages
Helpful Tools
Suggested Reading
Website TODO List
Support Forum
Download Visual Studio Add-In

Terms of Use
Privacy Policy
IPersistFile (Interfaces)

The IPersistFile interface provides methods that permit an object to be loaded from or saved to a disk file, rather than a storage object or stream. Because the information needed to open a file varies greatly from one application to another, the implementation of IPersistFile::Load on the object must also open its disk file.

The IPersistFile interface inherits its definition from IPersist, so all implementations must also include the GetClassID method of IPersist

C# Definition:

[ComImport, Guid("0000010b-0000-0000-C000-000000000046"),
public interface IPersistFile: IPersist
    new void GetClassID(out Guid pClassID);
    int IsDirty();

    void Load([In, MarshalAs(UnmanagedType.LPWStr)]
        string pszFileName, uint dwMode);

    void Save([In, MarshalAs(UnmanagedType.LPWStr)] string pszFileName,
        [In,MarshalAs(UnmanagedType.Bool)] bool fRemember);

    void SaveCompleted([In, MarshalAs(UnmanagedType.LPWStr)] string pszFileName);

    void GetCurFile([In, MarshalAs(UnmanagedType.LPWStr)] string ppszFileName);        

VB Definition:
.Net2 now includes this definition in System.Runtime.InteropServices.Comtypes namespace, but doesn't include return values for the methods

<ComImport(), Guid("0000010b-0000-0000-C000-000000000046"), _
   InterfaceType(ComInterfaceType.InterfaceIsIUnknown)> _
   Public Interface IPersistFile
    Inherits IPersist
    <PreserveSig()> Function IsDirty() As Integer
    <PreserveSig()> Function Load(<MarshalAs(UnmanagedType.LPWStr)> ByVal pszFileName As String, _
            ByVal dwMode As STGM) As HRESULT
    <PreserveSig()> Function Save(<MarshalAs(UnmanagedType.LPWStr)> ByVal pszFileName As String, _
            <MarshalAs(UnmanagedType.Bool)> ByVal fRemember As Boolean) As HRESULT
    <PreserveSig()> Function SaveCompleted(<MarshalAs(UnmanagedType.LPWStr)> ByVal pszFileName As String) As HRESULT
    ' CAUTION: This method is untested! It returns a value, so probably should be StringBuilder, but this
    '      disagrees with the C# definition above.
    <PreserveSig()> Function GetCurFile(<MarshalAs(UnmanagedType.LPWStr)> ByVal ppszFileName As Text.StringBuilder) As HRESULT
   End Interface

Please edit this page!

Do you have...

  • helpful tips?
  • corrections to the existing content?
  • alternate definitions?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing any supporting types needed.

Access directly from VS:
Terms of Use
Edit This Page
Find References
Show Printable Version