Rev 92 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 92 | Rev 93 | ||
---|---|---|---|
Line 14... | Line 14... | ||
14 | function GetDomainName(var outDomainName: WideString): boolean; |
14 | function GetDomainName(var outDomainName: WideString): boolean; |
15 | 15 | ||
16 | implementation |
16 | implementation |
17 | 17 | ||
18 | uses |
18 | uses |
- | 19 | {$IFDEF UNICODE} |
|
19 | iphlpapi, IpTypes, Iprtrmib, WinSock, Registry; |
20 | iphlpapi, IpTypes, Iprtrmib, |
- | 21 | {$ELSE} |
|
- | 22 | iphlp, |
|
- | 23 | {$ENDIF} |
|
- | 24 | WinSock, Registry; |
|
20 | 25 | ||
21 | // TODO: Replace GetAdaptersInfo()? A comment at MSDN states that there might be problems with IPv6 |
26 | // TODO: Replace GetAdaptersInfo()? A comment at MSDN states that there might be problems with IPv6 |
22 | // "GetAdaptersInfo returns ERROR_NO_DATA if there are only IPv6 interfaces |
27 | // "GetAdaptersInfo returns ERROR_NO_DATA if there are only IPv6 interfaces |
23 | // configured on system. In that case GetAdapterAddresses has to be used!" |
28 | // configured on system. In that case GetAdapterAddresses has to be used!" |
24 | 29 | ||
25 | function GetLocalIPAddressList(outsl: TStrings): DWORD; |
30 | function GetLocalIPAddressList(outsl: TStrings): DWORD; |
26 | var |
31 | var |
27 | pAdapterInfo: PIP_ADAPTER_INFO; |
32 | pAdapterInfo: PIP_ADAPTER_INFO; |
28 | addr: AnsiString; |
33 | addr: AnsiString; |
29 | addrStr: IP_ADDR_STRING; |
34 | addrStr: IP_ADDR_STRING; |
30 | BufLen: Cardinal; |
35 | BufLen: ULONG; |
31 | begin |
36 | begin |
32 | BufLen := SizeOf(IP_ADAPTER_INFO); |
37 | BufLen := SizeOf(IP_ADAPTER_INFO); |
33 | Result := GetAdaptersInfo(nil, BufLen); |
38 | Result := GetAdaptersInfo(nil, BufLen); |
34 | if Result <> ERROR_BUFFER_OVERFLOW then Exit; |
39 | if Result <> ERROR_BUFFER_OVERFLOW then Exit; |
35 | pAdapterInfo := AllocMem(BufLen); |
40 | pAdapterInfo := AllocMem(BufLen); |
Line 57... | Line 62... | ||
57 | function GetDHCPIPAddressList(outsl: TStrings): DWORD; |
62 | function GetDHCPIPAddressList(outsl: TStrings): DWORD; |
58 | var |
63 | var |
59 | pAdapterInfo: PIP_ADAPTER_INFO; |
64 | pAdapterInfo: PIP_ADAPTER_INFO; |
60 | addr: AnsiString; |
65 | addr: AnsiString; |
61 | addrStr: IP_ADDR_STRING; |
66 | addrStr: IP_ADDR_STRING; |
62 | BufLen: Cardinal; |
67 | BufLen: ULONG; |
63 | begin |
68 | begin |
64 | BufLen := SizeOf(IP_ADAPTER_INFO); |
69 | BufLen := SizeOf(IP_ADAPTER_INFO); |
65 | Result := GetAdaptersInfo(nil, BufLen); |
70 | Result := GetAdaptersInfo(nil, BufLen); |
66 | if Result <> ERROR_BUFFER_OVERFLOW then Exit; |
71 | if Result <> ERROR_BUFFER_OVERFLOW then Exit; |
67 | pAdapterInfo := AllocMem(BufLen); |
72 | pAdapterInfo := AllocMem(BufLen); |
Line 89... | Line 94... | ||
89 | function GetGatewayIPAddressList(outsl: TStrings): DWORD; |
94 | function GetGatewayIPAddressList(outsl: TStrings): DWORD; |
90 | var |
95 | var |
91 | pAdapterInfo: PIP_ADAPTER_INFO; |
96 | pAdapterInfo: PIP_ADAPTER_INFO; |
92 | addr: AnsiString; |
97 | addr: AnsiString; |
93 | addrStr: IP_ADDR_STRING; |
98 | addrStr: IP_ADDR_STRING; |
94 | BufLen: Cardinal; |
99 | BufLen: ULONG; |
95 | begin |
100 | begin |
96 | BufLen := SizeOf(IP_ADAPTER_INFO); |
101 | BufLen := SizeOf(IP_ADAPTER_INFO); |
97 | Result := GetAdaptersInfo(nil, BufLen); |
102 | Result := GetAdaptersInfo(nil, BufLen); |
98 | if Result <> ERROR_BUFFER_OVERFLOW then Exit; |
103 | if Result <> ERROR_BUFFER_OVERFLOW then Exit; |
99 | pAdapterInfo := AllocMem(BufLen); |
104 | pAdapterInfo := AllocMem(BufLen); |
Line 149... | Line 154... | ||
149 | end; |
154 | end; |
150 | 155 | ||
151 | function GetLocalMACAddressList(outSL: TStrings): DWORD; |
156 | function GetLocalMACAddressList(outSL: TStrings): DWORD; |
152 | var |
157 | var |
153 | pIfTable: PMIB_IFTABLE; |
158 | pIfTable: PMIB_IFTABLE; |
154 | TableSize: Cardinal; |
159 | TableSize: ULONG; |
155 | tmp: String; |
160 | tmp: String; |
156 | i, j: Integer; |
161 | i, j: Integer; |
157 | begin |
162 | begin |
158 | pIfTable := nil; |
163 | pIfTable := nil; |
159 | try |
164 | try |