如果vc 是托管程序,可以直接引用,如果非托管的
例如传递 vc++ 以下结构
typedef struct _SYSTEMTIME {
WORD wYear;
WORD wMonth;
WORD wDayOfWeek;
WORD wDay;
WORD wHour;
WORD wMinute;
WORD wSecond;
WORD wMilliseconds;
} SYSTEMTIME, *PSYSTEMTIME;
C# 这样写
[ StructLayout( LayoutKind.Sequential )]
public class SystemTime
{
public ushort year;
…
public ushort milliseconds;
}
public class LibWrap
{
// Declares a managed prototype for the unmanaged function.
[ DllImport( "Kernel32.dll" )]
public static extern void GetSystemTime( [In,Out] SystemTime st );
}