Skip to content

Instantly share code, notes, and snippets.

@toshiyukino
Last active December 31, 2015 05:09
Show Gist options
  • Save toshiyukino/7938831 to your computer and use it in GitHub Desktop.
Save toshiyukino/7938831 to your computer and use it in GitHub Desktop.
VBAでソケット通信初期化テスト
Private Declare Function WSAStartup Lib "ws2_32.dll" _
(ByVal wVersionRequested As Long, _
ByRef lpWSAData As WSADataType) As Long
Private Const WSA_DESCRIPTIONLEN As Long = 256
Private Const WSA_DESCRIPTIONSIZE As Long = WSA_DESCRIPTIONLEN + 1
Private Const WSA_SYS_STATUS_LEN As Long = 128
Private Const WSA_SYSSTATUSSIZE As Long = WSA_SYS_STATUS_LEN + 1
Private Type WSADataType
wVersion As Integer
wHighVersion As Integer
szDescription As String * WSA_DESCRIPTIONSIZE
szSystemStatus As String * WSA_SYSSTATUSSIZE
iMaxSockets As Integer
iMaxUdpDg As Integer
lpVendorInfo As Long
End Type
Private Declare Function WSACleanup Lib "ws2_32.dll" () As Long
Sub test()
Dim ret As Long
Dim wsaData As WSADataType
ret = WSAStartup(&H101, wsaData)
Debug.Print "wVersion = " & wsaData.wVersion
Debug.Print "wHighVersion = " & wsaData.wHighVersion
Debug.Print "szDescription = " & wsaData.szDescription
Debug.Print "szSystemStatus = " & wsaData.szSystemStatus
Debug.Print "iMaxSockets = " & wsaData.iMaxSockets
Debug.Print "iMaxUdpDg = " & wsaData.iMaxUdpDg
Debug.Print "lpVendorInfo = " & wsaData.lpVendorInfo
Debug.Print "wVersion = " & wsaData.wVersion
ret = WSACleanup()
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment