Note
Programing
2013年3月5日 星期二
C#呼叫DLL檔內指標參數使用
//宣告Intptr指標變數,初始記憶體位置大小
IntPtr ptr= Marshal.AllocHGlobal(Num * sizeof(int));
//傳入函式
MyFunction(..., ptr, ...);
//宣告陣列類型與大小
int[] p= new int[Num];
//將ptr內資料copy至陣列中
Marshal.Copy(ptr, p, 0, Num);
//釋放記憶體
Marshal.FreeHGlobal(ptr);
沒有留言:
張貼留言
較新的文章
較舊的文章
首頁
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言