a problem about WSAData!!!

  • Thread starter Thread starter crystalgirl
  • Start date Start date
C

crystalgirl

hi,everyone
how to declare it in c#? Thank you!!!
typedef struct WSAData {
WORD wVersion;
WORD wHighVersion;
char szDescription[WSADESCRIPTION_LEN+1];
char szSystemStatus[WSASYS_STATUS_LEN+1];
unsigned short iMaxSockets;
unsigned short iMaxUdpDg;
char FAR *lpVendorInfo;
} WSADATA, *LPWSADATA
 
crystalgirl, Have you tried to convert this struct yet yourself? Any
particular areas which you are having trouble with? Here's a quick
conversion which doesn't use const's but should work.

[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Ansi)]
public struct WSAData
{
public short UseVersion;
public short HighVersion;
[MarshalAs( UnmanagedType.ByValTStr, SizeConst=257 )]
public string Description;
[MarshalAs( UnmanagedType.ByValTStr, SizeConst=129 )]
public string SystemStatus;
public short MaxSockets;
public short MaxUdpDg;
public IntPtr VendorInfo;
}
 
Back
Top