سلام
راه اول:
function DUTGetUserDomain : String;
{
Obtains the domain the computer belongs to.
This is slow!
}
function GUDNetEnumerate(lpnr : PNetResource; Scope, ResourceType :
DWORD; const ComputerName : String; var DomainName : String) :
Boolean;
{
Private network enumeration recursive function.
lpnr should initially be Nil to start the enumeration at the
network's root.
Scope should be RESOURCE_GLOBALNET, RESOURCE_CONNECTED or
RESOURCE_REMEMBERED.
ResourceType should be RESOURCETYPE_ANY, RESOURCETYPE_DISK or
RESOURCETYPE_PRINT.
}
var
hEnum : THandle;
BufferSize,
NumEntries,
Entry : Integer;
lpnrLocalc, //Actually a pointer to an Array of TNetResource
P : PNetResource;
begin
Result := False;
if NO_ERROR <> WNetOpenEnum(Scope, ResourceType,
RESOURCEUSAGE_CONTAINER, lpnr, hEnum) then Exit;
try { hEnum }
BufferSize := 16384; { 16 Kib }
lpnrLocalc := AllocMem(BufferSize);
try { lpnrLocalc }
repeat
{ Get as many entries as possible; NumEntries will be
set to the number actually read (if successfull) }
NumEntries := $FFFFFFFF;
case WNetEnumResource(hEnum, NumEntries, lpnrLocalc,
BufferSize) of
NO_ERROR : begin
P := lpnrLocalc;
for Entry := 0 to (NumEntries - 1) do begin
{ P^.dwScope will be Scope since that is what we
asked for }
{
راه دوم:
interface
function NetWkstaGetInfo
(Servername : PWideChar;
level : DWORD;
bufPtr : POINTER) : DWORD; stdcall;
implementation
function NetWkstaGetInfo; external 'NETAPI32.DLL';