startup.bas
来自「Windows网络编程技术源码 (是Windows网络编程技术配套的一本源码教程」· BAS 代码 · 共 48 行
BAS
48 行
Attribute VB_Name = "startup"
'
' Project: vbpinfo
'
' Description:
' This is another simple app that shows you how to call the
' SO_PROTOCOL_INFO option.
'
Option Explicit
Sub Main()
Dim s As Long
Dim ret As Long
Dim pinf As WSAPROTOCOL_INFO
Dim iSize As Long
If Not TCPIPStartup Then
MsgBox "Windows Sockets not initialized. Error: " & Err.LastDllError & ". App shuts down."
Exit Sub
End If
s = WSASocket(AF_INET, SOCK_STREAM, IPPROTO_TCP, ByVal 0, 0, WSA_FLAG_OVERLAPPED)
's = WSASocket(AF_INET, SOCK_DGRAM, IPPROTO_UDP, ByVal 0, 0, WSA_FLAG_OVERLAPPED)
If s = INVALID_SOCKET Then
MsgBox "WSASocket failed. Error: " & Err.LastDllError & ". App shuts down."
Exit Sub
End If
iSize = LenB(pinf)
ret = getsockopt2(s, SOL_SOCKET, SO_PROTOCOL_INFOA, pinf, iSize)
If ret = SOCKET_ERROR Then
MsgBox "SO_PROTOCOL_INFOA failed. Error: " & Err.LastDllError
Exit Sub
End If
MsgBox "Protocol is " & pinf.iProtocol
closesocket s
TCPIPShutDown
MsgBox "Done! "
End Sub
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?