首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

关于C#与(C++)Com交互之数组传接

2013-03-22 
关于C#与(C++)Com交互之数组传递关于C#与(C)Com交互之数组传递通过C#分配内存空间给COMvoid SetDataToCom(

关于C#与(C++)Com交互之数组传递

关于C#与(C++)Com交互之数组传递

通过C#分配内存空间给COM

void SetDataToCom()

     {

                var arrayy = new int[3]{1,2,3};

                int size = Marshal.SizeOf(arrayy[0]) * arrayy.Length;
                marshalDataList = Marshal.AllocHGlobal(size);
                Marshal.Copy(arrayy, 0, marshalDataList, arrayy.Length);

                Mycom.SetCom(marshalDataList, arrayy.Length, false);//Set Value To Com

      }

 

void GetDataFormCom()

{

                int[] dataList = new int[10];
                int size = Marshal.SizeOf(dataList[0]) * dataList.Length;
                marshalDataList = Marshal.AllocHGlobal(size);

                Mycom.GetCom(marshalDataList, dataList.Length, true);//Get Value From Com
                Marshal.Copy(marshalDataList, dataList, 0, dataList.Length);

}

 

 

热点排行