如何将 C 结构转换为C#结构,以使用interopservices将其作为参数发送到非托管dll函数。
C 结构
typedef struct {
unsigned int opt,
NDVAL val,
byte type
} NDGETVAL;
typedef union
{
int i,
bool b,
float f,
char *t,
} NDVAL
答案 0 :(得分:0)
Converted c stracture to c#
[StructLayout( LayoutKind.Explicit )]
struct NDVAL
{
[FieldOffset( 0 )]
int i;
[FieldOffset( 0 )]
bool b;
[FieldOffset( 0 )]
float f;
[FieldOffset( 0 )]
IntPtr t;
}
class NDGETVAL
{
uint opt;
NDVAL val;
byte type;
}