'control Public Property Get LocalIP() As String LocalIP = AddrToIP(GetLocalHostName()) End Property'modulePublic Function GetLocalHostName() As String Dim s As String s = String(256, 0) If GetHostName(s, 256) = 0 Then
Dim l As Long l = InStr(s, vbNullChar) If l Then GetLocalHostName = Left(s, l - 1) Else GetLocalHostName = s End If End If End Function Public Function GetAscIP(ByVal IP As Long) As String
Dim l As Long l = inet_ntoa(IP) If l Then Dim lc As Long lc = lstrlen(l) If lc > 32 Then lc = 32 Dim s As String s = String(32, 0) CopyMemory ByVal s, ByVal l, lc s = Left$(s, lc) ' StrConv(LeftB$(s, lc), vbUnicode) GetAscIP = s Else GetAscIP = "255.255.255.255" End IfEnd Function Public Function AddrToIP(Host As String) As String AddrToIP = GetAscIP(GetHostByNameAlias(Host)) End Function
Public Property Get LocalIP() As String
LocalIP = AddrToIP(GetLocalHostName())
End Property'modulePublic Function GetLocalHostName() As String Dim s As String s = String(256, 0) If GetHostName(s, 256) = 0 Then
Dim l As Long
l = InStr(s, vbNullChar)
If l Then
GetLocalHostName = Left(s, l - 1)
Else
GetLocalHostName = s
End If
End If
End Function
Public Function GetAscIP(ByVal IP As Long) As String
Dim l As Long
l = inet_ntoa(IP) If l Then Dim lc As Long
lc = lstrlen(l) If lc > 32 Then lc = 32 Dim s As String
s = String(32, 0)
CopyMemory ByVal s, ByVal l, lc s = Left$(s, lc) ' StrConv(LeftB$(s, lc), vbUnicode) GetAscIP = s Else
GetAscIP = "255.255.255.255"
End IfEnd Function
Public Function AddrToIP(Host As String) As String
AddrToIP = GetAscIP(GetHostByNameAlias(Host))
End Function