|
|
function GetPDCName: string;
var
pDomain : PWideChar;
LibHandle : THandle;
begin
Result := '';
LibHandle := LoadLibrary(NTlib);
if LibHandle = 0 then
raise Exception.Create('Unable to map library: ' + NTlib);
try
@NTNetGetDCName := GetProcAddress(Libhandle, 'NetGetDCName');
@NTNetApiBufferFree := GetProcAddress(Libhandle, 'NetApiBufferFree');
try
if NTNetGetDCName(nil, nil, pDomain) = 0 then
Result := WideCharToString(pDomain);
finally
NTNetApiBufferFree(pDomain);
end;
finally
FreeLibrary(Libhandle);
end;
end;
function GetDomainName: AnsiString;
type
WKSTA_INFO_100 = record
wki100_platform_id: Integer;
wki100_computername: PWideChar;
wki100_langroup: PWideChar;
wki100_ver_major: Integer;
wki100_ver_minor: Integer;
end;
WKSTA_USER_INFO_1 = record
wkui1_username: PChar;
wkui1_logon_domain: PChar;
wkui1_logon_server: PChar;
wkui1_oth_domains: PChar;
end;
type
//Win9X ANSI prototypes from RADMIN32.DLL and RLOCAL32.DLL
TWin95_NetUserGetInfo = function(ServerName, UserName: PChar; Level: DWORD; var
BfrPtr: Pointer): Integer;
stdcall;
TWin95_NetApiBufferFree = function(BufPtr: Pointer): Integer;
stdcall;
TWin95_NetWkstaUserGetInfo = function(Reserved: PChar; Level: Integer; var
BufPtr: Pointer): Integer;
stdcall;
//WinNT UNICODE equivalents from NETAPI32.DLL
TWinNT_NetWkstaGetInfo = function(ServerName: PWideChar; level: Integer; var
BufPtr: Pointer): Integer;
stdcall;
TWinNT_NetApiBufferFree = function(BufPtr: Pointer): Integer;
stdcall;
var
Win95_NetUserGetInfo: TWin95_NetUserGetInfo;
Win95_NetWkstaUserGetInfo: TWin95_NetWkstaUserGetInfo;
Win95_NetApiBufferFree: TWin95_NetApiBufferFree;
WinNT_NetWkstaGetInfo: TWinNT_NetWkstaGetInfo;
WinNT_NetApiBufferFree: TWinNT_NetApiBufferFree;
WSNT: ^WKSTA_INFO_100;
WS95: ^WKSTA_USER_INFO_1;
EC: DWORD;
hNETAPI: THandle;
begin
try
Result := '';
if IsWinNT then
begin
hNETAPI := LoadLibrary('NETAPI32.DLL');
if hNETAPI <> 0 then
begin @WinNT_NetWkstaGetInfo := GetProcAddress(hNETAPI, 'NetWkstaGetInfo');
@WinNT_NetApiBufferFree := GetProcAd
网友评论:(评论内容只代表网友观点,与本站立场无关!) |
阅读排行
|