如何在c#中从c ++获取指向int指针的指针值

时间:2014-02-03 15:21:09

标签: c#-4.0

如何从intptr获取值数组。如何将int_ptr_arr指向的线索变成s1 [] ....意思是说我的s1 []应该包含10,100,15

如果它是Marshal.PtrToStringAnsi()的char **,它适用于我,但我想要它用于int **因为我没有像Marshal.ptrint()....等......

        enter code here
             Native code: 
       extern "C" __declspec(dllexport)    int**  __stdcall Array_hh()
            {
                int x=10;
                int y=100;
                int z=15;
             static int* myArray[3] = {&x, &y, &z};
                return myArray;
            }

            wrapper: 
[DllImport("Native_DLL.dll", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Auto)]
                     public static extern IntPtr Array_hh();
            void some_fun
             IntPtr int_ptr_arr = Wrapper.Array_hh();
                       int k = 0;
                       int[] s1 = new int[4];

0 个答案:

没有答案