I am trying to execute this function:
public static int QueryInterface( IntPtr pUnk, ref Guid iid, out IntPtr ppv )
Where
pUnk Type: System.IntPtr The interface to be queried.
Basically, Marshal.QueryInterface requests a pointer to the specified interface from a COM object. There are a number of interfaces that I would like to request (all from IPersist), so how do I need to get a link to these interfaces?
Note. IPersistStorage is one of them.
Edit (this works):
// Use the CLSID to instantiate the COM object using interop. Type type = Type.GetTypeFromCLSID(myGuid); Object comObj = Activator.CreateInstance(type); // Return a pointer to the objects IUnknown interface. IntPtr pIUnk = Marshal.GetIUnknownForObject(comObj); IntPtr pInterface; Int32 result = Marshal.QueryInterface(pIUnk, ref myGuid, out pInterface);
source share