Вниз
Скачать: CL | DM;

Список компьютеров в лок. сети   Найти похожие ветки 

← →
Stanislav ©   (2005-10-03 16:33) [0]

Подскажите пожалуйста как получить список всех компьютеров работающих в локальной сети ?


← →
alexbou   (2005-10-03 18:13) [1]

function TForm1.EnumNetRes(lpnr: PNetResource): Boolean;
type
 TNetResourceArray = array [0..65535] of TNetResource;
 PNRA = ^TNetResourceArray;
var
 dwResult, dwResultEnum: DWORD;
 hEnum: THandle;
 cbBuffer: DWORD;
 cEntries: DWORD;
 i: DWORD;
 lpnrLocal: PNRA;
begin
 cbBuffer := 16384;
 cEntries := DWORD(-1);

 dwResult := WNetOpenEnum(RESOURCE_GLOBALNET, RESOURCETYPE_ANY,
     0, lpnr, hEnum);

 if (dwResult <> NO_ERROR) then begin
//    ShowMessage("WNetEnumOpen error");
   Result := false;
   Exit;
 end;

 lpnrLocal := Pointer(GlobalAlloc(GPTR, cbBuffer));

 repeat
   // init buffer
   ZeroMemory(lpnrLocal, cbBuffer);

   // call WNetEnumResource
   dwResultEnum := WNetEnumResource(hEnum, cEntries, lpnrLocal, cbBuffer);

   // if success loop
   if dwResultEnum = NO_ERROR then
     for i := 0 to cEntries - 1 do begin
       Memo1.Lines.Add(lpnrLocal[i].lpRemoteName);
       Application.ProcessMessages;
       if not FSearch then break;
       if lpnrLocal[i].dwUsage and RESOURCEUSAGE_CONTAINER = RESOURCEUSAGE_CONTAINER then
         EnumNetRes(@lpnrLocal[i]);
     end
   else if dwResultEnum <> ERROR_NO_MORE_ITEMS then begin
//      ShowMessage("WNetEnumResource error");
     Result := false;
     Exit;
   end;

 until FSearch and not (dwResultEnum <> ERROR_NO_MORE_ITEMS);

 dwResult := WNetCloseEnum(hEnum);

 GlobalFree(Cardinal(lpnrLocal));

 if dwResult <> NO_ERROR then begin
//    ShowMessage("WNetCloseEnum error");
   Result := false;
   Exit
 end;

 Result := true;
end;


← →
alexbou   (2005-10-03 18:14) [2]

Вызов - EnumNetRes(nil), так как функция рекурсивная

Выдает верхние домены и хосты для всех сетевых служб


← →
Vetalich ©   (2005-10-18 23:48) [3]

А не подскажите как етим пользоваться...
очень надо...



Страницы: 1 вся ветка

Скачать: CL | DM;



Память: 0.45 MB
Время: 0.023 c
15-1136380135
Dasor
2006-01-04 16:08
2006.01.29
Помогите найти драйвер для мобилы


2-1136887592
Silver__Dragon
2006-01-10 13:06
2006.01.29
работа с эвентами EndDrag и EndDrop


6-1129522791
dreamse
2005-10-17 08:19
2006.01.29
Пропадает связь с сервисом после Logoff


15-1136983081
вразлет
2006-01-11 15:38
2006.01.29
Sound


15-1136064590
Игорь Шевченко
2006-01-01 00:29
2006.01.29
Наталия, с днем рождения!




   Наверх