1 Attribute VB_Name
= "modEth"
4 Public EthGateWay
As String
6 Public Const MAX_HOSTNAME_LEN
= 132
7 Public Const MAX_DOMAIN_NAME_LEN
= 132
8 Public Const MAX_SCOPE_ID_LEN
= 260
9 Public Const MAX_ADAPTER_NAME_LENGTH
= 260
10 Public Const MAX_ADAPTER_ADDRESS_LENGTH
= 8
11 Public Const MAX_ADAPTER_DESCRIPTION_LENGTH
= 132
12 Public Const ERROR_BUFFER_OVERFLOW
= 111
13 Public Const MIB_IF_TYPE_ETHERNET
= 1
14 Public Const MIB_IF_TYPE_TOKENRING
= 2
15 Public Const MIB_IF_TYPE_FDDI
= 3
16 Public Const MIB_IF_TYPE_PPP
= 4
17 Public Const MIB_IF_TYPE_LOOPBACK
= 5
18 Public Const MIB_IF_TYPE_SLIP
= 6
22 IpAddress
As String * 16
30 AdapterName
As String * MAX_ADAPTER_NAME_LENGTH
31 Description
As String * MAX_ADAPTER_DESCRIPTION_LENGTH
33 Address(MAX_ADAPTER_ADDRESS_LENGTH
- 1) As Byte
37 CurrentIpAddress
As Long
38 IpAddressList
As IP_ADDR_STRING
39 GatewayList
As IP_ADDR_STRING
40 DhcpServer
As IP_ADDR_STRING
42 PrimaryWinsServer
As IP_ADDR_STRING
43 SecondaryWinsServer
As IP_ADDR_STRING
49 HostName
As String * MAX_HOSTNAME_LEN
50 DomainName
As String * MAX_DOMAIN_NAME_LEN
51 CurrentDnsServer
As Long
52 DnsServerList
As IP_ADDR_STRING
54 ScopeId
As String * MAX_SCOPE_ID_LEN
60 Public Declare Function GetNetworkParams
Lib "IPHlpApi" (FixedInfo
As Any
, pOutBufLen
As Long) As Long
61 Public Declare Function GetAdaptersInfo
Lib "IPHlpApi" (IpAdapterInfo
As Any
, pOutBufLen
As Long) As Long
62 Public Declare Sub CopyMemory
Lib "kernel32" Alias "RtlMoveMemory" (Destination
As Any
, Source
As Any
, ByVal Length
As Long)
66 Dim FixedInfoSize
As Long
67 Dim AdapterInfoSize
As Long
69 Dim PhysicalAddress
As String
71 Dim AdapterInfo
As IP_ADAPTER_INFO
72 Dim Adapt
As IP_ADAPTER_INFO
73 Dim AddrStr
As IP_ADDR_STRING
74 Dim FixedInfo
As FIXED_INFO
75 Dim Buffer
As IP_ADDR_STRING
78 Dim Buffer2
As IP_ADAPTER_INFO
79 Dim FixedInfoBuffer() As Byte
80 Dim AdapterInfoBuffer() As Byte
81 'Get the main IP configuration information for this machine using a FIXED_INFO structure
83 error = GetNetworkParams(ByVal 0&, FixedInfoSize
)
86 If error <> ERROR_BUFFER_OVERFLOW
Then
87 ' MsgBox "GetNetworkParams sizing failed with error " & error
92 ReDim FixedInfoBuffer(FixedInfoSize
- 1)
93 error = GetNetworkParams(FixedInfoBuffer(0), FixedInfoSize
)
96 CopyMemory FixedInfo
, FixedInfoBuffer(0), Len(FixedInfo
)
97 ' MsgBox "Host Name: " & FixedInfo.HostName
98 ' MsgBox "DNS Servers: " & FixedInfo.DnsServerList.IpAddress
99 pAddrStr
= FixedInfo
.DnsServerList
.Next
101 Do While pAddrStr
<> 0
102 CopyMemory Buffer
, ByVal pAddrStr
, Len(Buffer
)
103 ' MsgBox "DNS Servers: " & Buffer.IpAddress
104 pAddrStr
= Buffer
.Next
107 ' MsgBox "NetBIOS Scope ID: " & FixedInfo.ScopeId
109 If FixedInfo
.EnableRouting
Then
110 ' MsgBox "IP Routing Enabled "
112 ' MsgBox "IP Routing not enabled"
115 If FixedInfo
.EnableProxy
Then
116 ' MsgBox "WINS Proxy Enabled "
118 ' MsgBox "WINS Proxy not Enabled "
121 If FixedInfo
.EnableDns
Then
122 ' MsgBox "NetBIOS Resolution Uses DNS "
124 ' MsgBox "NetBIOS Resolution Does not use DNS "
128 ' MsgBox "GetNetworkParams failed with error " & error
132 'Enumerate all of the adapter specific information using the IP_ADAPTER_INFO structure.
133 'Note: IP_ADAPTER_INFO contains a linked list of adapter entries.
135 error = GetAdaptersInfo(ByVal 0&, AdapterInfoSize
)
138 If error <> ERROR_BUFFER_OVERFLOW
Then
139 ' MsgBox "GetAdaptersInfo sizing failed with error " & error
144 ReDim AdapterInfoBuffer(AdapterInfoSize
- 1)
145 ' Get actual adapter information
146 error = GetAdaptersInfo(AdapterInfoBuffer(0), AdapterInfoSize
)
149 ' MsgBox "GetAdaptersInfo failed with error " & error
153 CopyMemory AdapterInfo
, AdapterInfoBuffer(0), Len(AdapterInfo
)
154 pAdapt
= AdapterInfo
.Next
155 CopyMemory Buffer2
, AdapterInfo
, Len(Buffer2
)
157 ' MsgBox " AdapterName: " & Buffer2.AdapterName
158 ' MsgBox "AdapterDescription: " & Buffer2.Description
160 For i
= 0 To Buffer2
.AddressLength
- 1
161 PhysicalAddress
= PhysicalAddress
& Hex(Buffer2
.Address(i
))
163 If i
< Buffer2
.AddressLength
- 1 Then
164 PhysicalAddress
= PhysicalAddress
& "-"
169 ' MsgBox "Physical Address: " & PhysicalAddress
171 If Buffer2
.DhcpEnabled
Then
172 ' MsgBox "DHCP Enabled "
174 ' MsgBox "DHCP disabled"
177 pAddrStr
= Buffer2
.IpAddressList
.Next
179 ' MsgBox "Default Gateway: " & Buffer2.GatewayList.IpAddress
180 EthGateWay
= Replace
$(Buffer2.GatewayList.IpAddress, Chr(0), "")