in die Deklarationen
Type HOSTENT
hName As Long
hAliases As Long
hAddrType As Integer
hLen As Integer
hAddrList As Long
End Type
Declare Function gethostname Lib "WSOCK32.DLL" (Byval szHost As String, Byval dwHostLen As Long) As Long
Declare Function gethostbyname Lib "WSOCK32.DLL" (Byval szHost As String) As Long
Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (hpvDest As Any, Byval hpvSource As Long, Byval cbCopy As Long)
und ins Click
Sub Click(Source As Button)
Dim HostName As String * 256
Dim HostPointer As Long
Dim HostStruct As HOSTENT
Dim HostAddressPointer As Long
Dim HostAddress As Long
Dim AddressNum As String
Dim Address As String
gethostname HostName, 256
HostName = Trim(HostName)
HostPointer = gethostbyname(HostName)
CopyMemory HostStruct, HostPointer, Len(HostStruct)
CopyMemory HostAddressPointer, HostStruct.hAddrList, 4
CopyMemory HostAddress, HostAddressPointer, 4
AddressNum = Trim(Hex(HostAddress))
AddressNum = String(8-Len(AddressNum), Asc("0")) & AddressNum
Address = Cstr(Cint("&H" & Mid(AddressNum, 7))) & "." & Cstr(Cint("&H" & Mid(AddressNum, 5, 2))) & "." & Cstr(Cint("&H" & Mid(AddressNum, 3, 2))) & "." & Cstr(Cint("&H" & Left(AddressNum, 2)))
Msgbox Address
End Sub
aber ob das jetzt einfacher ist ??
ach ja, wir hatten das auch mal als Klasse
http://www.eknori.de/downloads/cSysInfo.zipda sind dann noch ein paar Funktionen mehr drin.