我發現了一個代碼,可以執行directx com導入。但我不明白它,它也不適用於我的代碼。C#使用指針奇怪的方法調用?
正是這種代碼:
internal unsafe Result GetCapabilities(out BufferCapabilities dSBufferCapsRef)
{
BufferCapabilities.__Native native = BufferCapabilities.__NewNative();
Result result = (Result) **(((IntPtr*) base._nativePointer))[(int) (((IntPtr) 3) * sizeof(void*))](base._nativePointer, (IntPtr) &native);
dSBufferCapsRef = new BufferCapabilities();
dSBufferCapsRef.__MarshalFrom(ref native);
result.CheckError();
return result;
}
奇怪線是兩線的方法。結果結果= .... _nativePointer聲明如下:
protected unsafe void* _nativePointer;
所以我的答案怎麼可能叫指針指的的cominterface的成員。我怎樣才能調用這個:(base._nativePointer,(IntPtr)& native)。 它是指針_nativePointer指向的接口的成員。
我知道我有點困惑,但我希望你能理解我的問題。
看起來它是直接調用COM接口的第4個函數。可能是IDirectSoundBuffer8 :: GetCaps()。你不想維護這段代碼,把它扔掉。 –