C结构体里包含有结构指针成员,这样的结构如何转换为C#的结构体typedef struct{
int a;
int b;
}StructA, *LPStructA
typedef struct{
int a;
LPStructA structA;
}StructB
第二个结构体如何转为C#的形式
int a;
int b;
}StructA, *LPStructA
typedef struct{
int a;
LPStructA structA;
}StructB
第二个结构体如何转为C#的形式
public struct StructB
{
public int a;
public IntPtr structA;
}
但是我在使用回传的StructB数据时,怎么知道IntPtr structA就是LPStructA structA,使用
强制转换(StructA)structA吗
int a;
int b;
}StructA, *LPStructA
这个也定义一遍,然后
StructA sa = (StructA)Marshal.PtrToStructure(StructB.structA, typeof(StructA));
{
public int a;
public int b;
};
public struct StructB : IDisposable
{
public int a;
public IntPtr structA; public void Dispose()
{
System.Runtime.InteropServices.Marshal.FreeHGlobal(structA);
}
public StructA StructA
{
get
{
return (StructA)System.Runtime.InteropServices.Marshal.PtrToStructure(structA, typeof(StructA));
}
}
}