110,561
社区成员
发帖
与我相关
我的任务
分享
struct MyStruct
{
MyStruct * next;
int i;
};
extern "C" char test(MyStruct ms)
{
return 's';
}
extern "C" int t()
{
return 1;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public struct MyStruct
{
public IntPtr next;
public int i;
};
[DllImport(@"ConsoleApplication2.dll", CharSet = CharSet.Unicode)]
public static extern char test(MyStruct ms);
[DllImport(@"ConsoleApplication2.dll", CharSet = CharSet.Unicode)]
public static extern int t();
static void Main(string[] args)
{
int i = t();
MyStruct m = new MyStruct();
IntPtr pv = Marshal.AllocHGlobal(10);
Marshal.WriteInt32(pv, 10);
test(m);
}