[英]Facing issue converting C structure to C# structure while accessing unmanaged C/C++ dll function
我如何使用interopservices將C結構轉換為C #結構以將其作為參數發送給非托管dll函數。
C結構
typedef struct {
unsigned int opt,
NDVAL val,
byte type
} NDGETVAL;
typedef union
{
int i,
bool b,
float f,
char *t,
} NDVAL
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;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.