110,574
社区成员
发帖
与我相关
我的任务
分享
struct MyPoint
{
int x;
int y;
};
#include"stdio.h"
void _declspec(dllexport) TestFunc(MyPoint *p,int nItemCount)
{
FILE* f = fopen("c:\\mypoint.txt","w");
for(int i=0;i<nItemCount;i++)
{
fwrite(&p[i].x,sizeof(int),1,f);
fwrite(":",sizeof(char),1,f);
fwrite(&p[i].y,sizeof(int),1,f);
}
fclose(f);
}
struct Mypoint
{
public int x;
public int y;
}
[DllImport(@"E:\个人文件\Source\VS\test\Test_c_Console\debug\Test_c_Dll.dll")]
private static extern void TestFunc([In, Out] Mypoint[] p, int i);
private void button1_Click(object sender, EventArgs e)
{
Mypoint[] p = new Mypoint[50];
for (int i = 0; i < 50; i++)
{
p[i].x = i;
p[i].y = i ;
}
TestFunc(p, 50);
}