Форум: "WinAPI";
Текущий архив: 2002.12.19;
Скачать: [xml.tar.bz2];
ВнизИмена компов в сети!!! Найти похожие ветки
← →
9999 (2002-11-06 15:18) [0]Hello! Как получить список имен компов в сети? Спасибо!!!
← →
kostik78ua (2002-11-06 16:03) [1]uses Winsock,...
var
Domain, Computer, Hosts : Array[1..500] of String[25];
// Поиск доменов в сети
function FindAllDomains: integer;
Var
EnumHandle : THandle;
WorkgroupRS : TNetResource;
Buf : Array[1..500] of TNetResource;
BufSize : Cardinal;
Entries : Cardinal;
wResult : Cardinal;
begin
Result := 0;
FillChar(WorkgroupRS, SizeOf(WorkgroupRS) , 0);
With WorkgroupRS do begin
dwScope := RESOURCE_GLOBALNET;
dwType := RESOURCETYPE_ANY;
dwDisplayType := RESOURCEDISPLAYTYPE_DOMAIN;
dwUsage := RESOURCEUSAGE_CONTAINER;
lpProvider := "Сеть Microsoft Windows";
end;
WNetOpenEnum( RESOURCE_GLOBALNET,
RESOURCETYPE_ANY,
0,
@WorkgroupRS,
EnumHandle );
Repeat
Entries := 1;
BufSize := SizeOf(Buf);
wResult :=
WNetEnumResource( EnumHandle,
Entries,
@Buf,
BufSize );
If (wResult = NO_ERROR) and (Entries = 1) then begin
Inc( Result );
Domain[ Result ] := StrPas(Buf[1].lpRemoteName);
end;
Until (Entries <> 1) or (wResult <> NO_ERROR);
WNetCloseEnum( EnumHandle );
end; { Find All Domains }
// Поиск компьютеров в домене
function FindAllComputers(Workgroup: String): integer;
Var
EnumHandle : THandle;
WorkgroupRS : TNetResource;
Buf : Array[1..500] of TNetResource;
BufSize : Cardinal;
Entries : Cardinal;
wResult : Cardinal;
WSAData : TWSAData;
pName: PChar;
p: PHostEnt;
begin
WSAStartup($0101, WSAData);
Result := 0;
Workgroup := Workgroup + #0;
FillChar(WorkgroupRS, SizeOf(WorkgroupRS) , 0);
With WorkgroupRS do begin
dwScope := RESOURCE_GLOBALNET;
dwType := RESOURCETYPE_ANY;//3;
dwDisplayType := RESOURCEDISPLAYTYPE_DOMAIN;
dwUsage := RESOURCEUSAGE_CONTAINER;
lpRemoteName := @Workgroup[1];
end;
WNetOpenEnum( RESOURCE_GLOBALNET,
RESOURCETYPE_ANY,
0,
@WorkgroupRS,
EnumHandle );
Repeat
Entries := 1;
BufSize := SizeOf(Buf);
wResult :=
WNetEnumResource( EnumHandle,
Entries,
@Buf,
BufSize );
If (wResult = NO_ERROR) and (Entries = 1) then begin
Inc( Result );
Computer[ Result ] := StrPas(Buf[1].lpRemoteName);
pName:=Buf[1].lpRemoteName+2;
p:=GetHostByName(pName);
if p<>nil then Hosts[ Result ] := inet_ntoa(PInAddr(p.h_addr_list^)^) else Hosts[ Result ] := "";
end;
Until (Entries <> 1) or (wResult <> NO_ERROR);
WNetCloseEnum( EnumHandle );
WSACleanup;
end; { Find All Computers }
Страницы: 1 вся ветка
Форум: "WinAPI";
Текущий архив: 2002.12.19;
Скачать: [xml.tar.bz2];
Память: 0.45 MB
Время: 0.007 c