Rev 71 | Rev 92 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 71 | Rev 73 | ||
---|---|---|---|
Line 9... | Line 9... | ||
9 | function GetLocalMACAddressList(outSL: TStrings): DWORD; |
9 | function GetLocalMACAddressList(outSL: TStrings): DWORD; |
10 | function GetDHCPIPAddressList(outsl: TStrings): DWORD; |
10 | function GetDHCPIPAddressList(outsl: TStrings): DWORD; |
11 | function GetGatewayIPAddressList(outsl: TStrings): DWORD; |
11 | function GetGatewayIPAddressList(outsl: TStrings): DWORD; |
12 | function GetMACAddress(const IPAddress: string; var outAddress: string): DWORD; |
12 | function GetMACAddress(const IPAddress: string; var outAddress: string): DWORD; |
13 | function FormatMAC(s: string): string; |
13 | function FormatMAC(s: string): string; |
- | 14 | function GetDomainName(var outDomainName: WideString): boolean; |
|
14 | 15 | ||
15 | implementation |
16 | implementation |
16 | 17 | ||
17 | uses |
18 | uses |
18 | iphlp, WinSock; |
19 | iphlp, WinSock, Registry; |
19 | 20 | ||
20 | // TODO: Replace GetAdaptersInfo()? A comment at MSDN states that there might be problems with IPv6 |
21 | // TODO: Replace GetAdaptersInfo()? A comment at MSDN states that there might be problems with IPv6 |
21 | // "GetAdaptersInfo returns ERROR_NO_DATA if there are only IPv6 interfaces |
22 | // "GetAdaptersInfo returns ERROR_NO_DATA if there are only IPv6 interfaces |
22 | // configured on system. In that case GetAdapterAddresses has to be used!" |
23 | // configured on system. In that case GetAdapterAddresses has to be used!" |
23 | 24 | ||
Line 211... | Line 212... | ||
211 | result := result + Copy(s, m, 2); |
212 | result := result + Copy(s, m, 2); |
212 | inc(m, 2); |
213 | inc(m, 2); |
213 | until m > Length(s); |
214 | until m > Length(s); |
214 | end; |
215 | end; |
215 | 216 | ||
- | 217 | (* |
|
- | 218 | type |
|
- | 219 | WKSTA_INFO_100 = Record |
|
- | 220 | wki100_platform_id : DWORD; |
|
- | 221 | wki100_computername : LPWSTR; |
|
- | 222 | wki100_langroup : LPWSTR; |
|
- | 223 | wki100_ver_major : DWORD; |
|
- | 224 | wki100_ver_minor : DWORD; |
|
- | 225 | End; |
|
- | 226 | ||
- | 227 | LPWKSTA_INFO_100 = ^WKSTA_INFO_100; |
|
- | 228 | ||
- | 229 | function GetNetParam(AParam: integer): string; |
|
- | 230 | Var |
|
- | 231 | PBuf : LPWKSTA_INFO_100; |
|
- | 232 | Res : LongInt; |
|
- | 233 | begin |
|
- | 234 | result := ''; |
|
- | 235 | Res := NetWkstaGetInfo(nil, 100, @PBuf); |
|
- | 236 | If Res = NERR_Success Then |
|
- | 237 | begin |
|
- | 238 | case AParam of |
|
- | 239 | 0: Result := string(PBuf^.wki100_computername); |
|
- | 240 | 1: Result := string(PBuf^.wki100_langroup); |
|
- | 241 | end; |
|
- | 242 | end; |
|
- | 243 | end; |
|
- | 244 | ||
- | 245 | function GetTheComputerName: string; |
|
- | 246 | begin |
|
- | 247 | Result := GetNetParam(0); |
|
- | 248 | end; |
|
- | 249 | ||
- | 250 | function GetTheDomainName: string; |
|
- | 251 | begin |
|
- | 252 | Result := GetNetParam(1); |
|
- | 253 | end; |
|
- | 254 | ||
- | 255 | *) |
|
- | 256 | ||
- | 257 | function GetDomainName(var outDomainName: WideString): boolean; |
|
- | 258 | var |
|
- | 259 | reg: TRegistry; |
|
- | 260 | begin |
|
- | 261 | outDomainName := ''; |
|
- | 262 | reg := TRegistry.Create; |
|
- | 263 | try |
|
- | 264 | reg.RootKey := HKEY_LOCAL_MACHINE; |
|
- | 265 | result := reg.OpenKeyReadOnly('\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters'); |
|
- | 266 | if result then |
|
- | 267 | begin |
|
- | 268 | outDomainName := reg.ReadString('Domain'); |
|
- | 269 | reg.CloseKey; |
|
- | 270 | end; |
|
- | 271 | finally |
|
- | 272 | reg.Free; |
|
- | 273 | end; |
|
- | 274 | end; |
|
- | 275 | ||
216 | end. |
276 | end. |