In C#, is there an easy way to call a COM object method from a native pointer?
[DllImport("d3d11.dll", CallingConvention = CallingConvention.StdCall)]
private unsafe static extern int D3D11CreateDevice(
void* arg0, int arg1, void* arg2, int arg3, void* arg4,
int arg5, int arg6, void* arg7, void* arg8, void* arg9);
public static void CreateDevice()
{
unsafe
{
IntPtr deviceOut;
IntPtr immediateContextOut;
int featureLevelRef;
D3D11CreateDevice(
(void*)IntPtr.Zero,
1,
(void*)IntPtr.Zero,
32,
(void*)IntPtr.Zero,
0,
7,
&deviceOut,
&featureLevelRef,
&immediateContextOut);
}
}
In the code above, I get deviceOut whose type is ID3D11Device*. The ID3D11Device interface has a bunch of methods such as CreateBuffer().
Can I call some of these methods using deviceOut pointer? Thank you in advance.