![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
Как найти все комьютеры в сети 3Delphi , Интернет и Сети , Сеть
Автор: SmaLL function EnumerateFunc(hwnd: HWND; hdc: HDC; lpnr: PNetResource): Boolean; const cbBuffer: DWORD = 16384; // 16K is a good size var hEnum, dwResult, dwResultEnum: DWORD; lpnrLocal: array [0..16384 div SizeOf(TNetResource)] of TNetResource; // pointer to enumerated structures i: integer; cEntries: Longint; begin centries := -1; // enumerate all possible entries // Call the WNetOpenEnum function to begin the enumeration. dwResult := WNetOpenEnum( RESOURCE_CONTEXT, // Enumerate currently connected resources. RESOURCETYPE_DISK, // all resources 0, // enumerate all resources lpnr, // NULL first time the function is called hEnum // handle to the resource ); if (dwResult <> NO_ERROR) then begin // Process errors with an application-defined error handler Result := False; Exit; end; // Initialize the buffer. FillChar(lpnrLocal, cbBuffer, 0); // Call the WNetEnumResource function to continue // the enumeration. dwResultEnum := WNetEnumResource(hEnum, // resource handle DWORD(cEntries), // defined locally as -1 @lpnrLocal, // LPNETRESOURCE cbBuffer); // buffer size // This is just printing for i := 0 to cEntries - 1 do begin // loop through each structure and // get remote name of resource... lpnrLocal[i].lpRemoteName) end; // Call WNetCloseEnum to end the enumeration. dwResult := WNetCloseEnum(hEnum); if (dwResult <> NO_ERROR) then begin // Process errors... some user defined function here Result := False; end else Result := True; end; Программный код на Delphi, использующий Windows API для перечисления всех компьютеров (ресурсов типа
Чтобы найти все компьютеры (ресурсы типа
Обратите внимание, что это код assumes that you have the necessary permissions to enumerate resources on the network. Additionally, the В статье описывается функция EnumerateFunc, которая позволяет найти и enumerated all computers on the network using Delphi. Комментарии и вопросыПолучайте свежие новости и обновления по Object Pascal, Delphi и Lazarus прямо в свой смартфон. Подпишитесь на наш Материалы статей собраны из открытых источников, владелец сайта не претендует на авторство. Там где авторство установить не удалось, материал подаётся без имени автора. В случае если Вы считаете, что Ваши права нарушены, пожалуйста, свяжитесь с владельцем сайта.
|
||||
©KANSoftWare (разработка программного обеспечения, создание программ, создание интерактивных сайтов), 2007 |