Главная страница
    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.007 c
14-61774
AngeL B.
2002-11-27 17:10
2002.12.19
сколько может стоить программа?


1-61598
vilfred
2002-12-09 19:36
2002.12.19
один массив побить на десять


1-61695
Dancho
2002-12-09 00:14
2002.12.19
Контейнер компонентов


1-61576
Levsha
2002-12-09 22:44
2002.12.19
Как изменить цвет строки в DBgrid?


3-61463
Larisa
2002-11-26 00:32
2002.12.19
Создание отчета в MS Word.





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
Английский Французский Немецкий Итальянский Португальский Русский Испанский