Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


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

IPersistStream (Interfaces)
 
.

    /// <summary>
    /// Definition for interface IPersist.
    /// </summary>
    [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("0000010c-0000-0000-C000-000000000046")]
    public interface IPersist {
        /// <summary>
        /// getClassID
        /// </summary>
        /// <param name="pClassID"></param>
        void GetClassID( /* [out] */ out Guid pClassID);
    };
    /// <summary>
    /// Definition for interface IPersistStream.
    /// </summary>
    [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("00000109-0000-0000-C000-000000000046")]
    public interface IPersistStream : IPersist {
        /// <summary>
        /// getClassID
        /// </summary>
        /// <param name="pClassID"></param>
          new void GetClassID(out Guid pClassID);    
        /// <summary>
        /// isDirty
        /// </summary>
        /// <returns></returns>
        [PreserveSig]
        int IsDirty( );
        /// <summary>
        /// Load
        /// </summary>
        /// <param name="pStm"></param>
        void Load([In] IStream pStm);
        /// <summary>
        /// Save
        /// </summary>
        /// <param name="pStm"></param>
        /// <param name="fClearDirty"></param>
        void Save([In] IStream pStm, [In, MarshalAs(UnmanagedType.Bool)] bool fClearDirty);
        /// <summary>
        /// GetSizeMax
        /// </summary>
        /// <param name="pcbSize"></param>
        void GetSizeMax(out long pcbSize);
    };

Summary
TODO - a short description

C# Definition:

//from http://msdn.microsoft.com/en-US/library/microsoft.visualstudio.ole.interop.ipersiststreaminit.save(v=vs.80).aspx

[ComImport]
[Guid("7FD52380-4E07-101B-AE2D-08002B2EC713")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
interface IPersistStreamInit {
    int GetClassID (out Guid pClassID);
    void GetSizeMax ([OutAttribute] ulong[] pcbSize);    
    void InitNew ();
    int IsDirty ();    
    void Load ([InAttribute] IStream pstm);
    void Save ([InAttribute] IStream pstm, [InAttribute] int fClearDirty);
}

VB Definition:

<ComImport> _
<Guid("7FD52380-4E07-101B-AE2D-08002B2EC713")> _
'TODO: Insert <InterfaceType(ComInterfaceType.InterfaceIsIUnknown)> _ if this doesn't derive from IDispatch
Interface IPersistStreamInit
   TODO
End Interface

User-Defined Types:

None.

Notes:

None.

     // Example -----------------------Note: In C#, use IPersistStreamInit ----------------------
    public  string    _strErrorMsg;

Documentation

    public string GetComObjectGUID(object objComCtrl)
    {
        IntPtr pIPStream = IntPtr.Zero;
        string strStreamGUID = "NONE";
        IntPtr pActiveXObj = IntPtr.Zero;
        int iResult;
        int S_OK = 0;
        int E_FAIL = unchecked((int)0x80004005);
        int E_NOINTERFACE = unchecked((int)0x80004002);
        Guid IID_IPersistStreamInit = new Guid("7FD52380-4E07-101B-AE2D-08002B2EC713");

        if (objComCtrl.GetType().IsCOMObject)
        {
              pActiveXObj = Marshal.GetIUnknownForObject((object)objComCtrl);
            if (pActiveXObj == IntPtr.Zero)
            {
                ErrorMsg = "GetIUnknownForObject was zero.";
            }
            else
            {
               iResult = Marshal.QueryInterface(pActiveXObj, ref IID_IPersistStreamInit, out pIPStream);
               if (iResult == E_NOINTERFACE)
               {
                    ErrorMsg = "No such interface supported";
               }            
               else if (iResult == E_FAIL)
               {
                    ErrorMsg = "PersistStreamInit QueryInit failed.";
               }
               else if (iResult == S_OK)
               {
                    IPersistStreamInit pPersistStream = (
                    IPersistStreamInit)Marshal.GetObjectForIUnknown(pIPStream);
                    Guid ptrClsId;
                    IPersist pPersist = (IPersist)pPersistStream ;
                    pPersist.GetClassID(out ptrClsId);
                    strStreamGUID = ptrClsId.ToString().ToUpper();
               }
            }
               Marshal.Release(pActiveXObj); // not releasing gives a memory leak
               Marshal.Release(pIPStream);

        }
        return (strStreamGUID);
    }

    public string ErrorMsg
     {
          get {return _strErrorMsg;}
          set {_strErrorMsg = value;}
     }

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 PInvoke.net directly from VS:
Terms of Use
Edit This Page
Find References
Show Printable Version
Revisions