| Private Function GetIPAddress() As String On Error GoTo Z Dim wsa As WSAData Dim rVal As Long Dim sHost As String * 256 Dim lp As Long Dim lpa As Long Dim IpAdr(0 To 3) As Byte rVal = WSAStartup((2 + &H100), wsa) If rVal = 0 Then gethostname sHost, 256 lp = gethostbyname(sHost) If lp Then CopyMemoryIP lpa, lp + 16, 4 CopyMemoryIP IpAdr(0), lpa, 4 GetIPAddress = CStr(IpAdr(0)) & "." & CStr(IpAdr(1)) & "." & CStr(IpAdr(2)) & "." & CStr(IpAdr(3)) End If WSACleanup End If Exit Function Z: GetIPAddress = "" End Function Private Sub Command1_Click() Dim ret As String ret = GetIPAddress If ret <> "" Then MsgBox "当前计算机网卡IP:" & ret End If End Sub |