我試圖讀取一個數組,它是由C#編寫的一個dll函數創建的。當我打印出陣列的內容時,它實際上已經是垃圾了。編組const float **的正確方法是什麼?
我懷疑這是因爲我錯誤地將const float**
編爲out IntPtr
。你如何正確編組const float**
?
DLL C++接口
int Foo(void *objPtr, uint64_t *resultLen, const float **result);
DLL導入語句
[DllImport("foo.dll", CharSet = CharSet.Auto)]
public static extern int Foo(IntPtr objPtr, out ulong resultLen, out IntPtr result);
長途區號
IntPtr objPtr = getObj();
IntPtr result;
ulong resultLen;
int output = Foo(objPtr, out resultLen, out result);
調用該函數 –
你可以考慮使用C++/CLI而不是P的例子所示的C++代碼/調用 –