Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "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.008 c
3-61416
Sirus
2002-11-29 12:42
2002.12.19
Можно ли перехватить сообщение об ошибке


1-61557
Vcoder
2002-12-05 21:09
2002.12.19
Unicode символы


1-61533
andrew
2002-12-09 13:51
2002.12.19
Перерисовка controls


1-61601
olden
2002-12-06 18:56
2002.12.19
как избежать прокрутки комбобокса колесом мышки


1-61693
vitnt
2002-12-09 06:49
2002.12.19
Печать формы





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский