Search code examples
c#virtual-channelwtsapi32

Export VirtualChannelGetInstance function from c#


I want to export this function from C#:

HRESULT VCAPITYPE VirtualChannelGetInstance(
 _In_    REFIID refiid,
 _Inout_ ULONG  *pNumObjs,
 _Out_   VOID   **ppObjArray
);

I have tried following code:

public static uint VirtualChannelGetInstance(IntPtr refiid, ref uint pNumObjs, ref IntPtr[] ppObjArray)  
{
      MessageBox.Show("VirtualChannelGetInstance ");
      return 0; 
}

The problem is when this exported funciton from C# is called, I always get nullreference exception. What could be a problem?


Solution

  • I got this working by changing VirtualChannelGetInstance declaration:

    public static uint VirtualChannelGetInstance(Guid refiid, ref ulong pNumObjs, void** ppObjArray)