回覆列表
  • 1 # 使用者6847486145697

    原型:int PASCAL FAR WSAStartup(WORD wVersionRequested, LPWSADATA lpWSAData );

    [DllImport("ws2_32.dll")]

    public static extern Int32 WSAStartup(UInt16 wVer, ref WSADATA wsaData);

    public struct WSADATA //這樣宣告結構體

    {

    public short wVersion;

    public short wHighVersion;

    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 6)]

    public string szDescription;

    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 6)]

    public string szSystemStatus;

    [Obsolete]

    public int wMaxSockets;

    [Obsolete]

    public int wMAXUDPDG;

    public IntPtr dwVendorInfo;

    }

    例項化結構體:

    WSADATA wsaData = new WSADATA();

    WSAStartup(0x0202, ref wsaData); //注意第二個引數前的ref ,0x202指Socket的版本號

  • 中秋節和大豐收的關聯?
  • SNH48和AKB48是什麼關係?