2008. március 17., hétfő
Enumerating workgroups on your LAN
Problem/Question/Abstract:
Enumerating workgroups on your LAN.
Answer:
{ This code is a copy-paste from a working application.
}
var
WorkgroupCount: Integer;
Workgroup: array[1..500] of string[25];
procedure FindAllWorkgroups;
var
EnumHandle: THandle;
EntireNetwork: TNetResource;
Buf: array[1..500] of TNetResource;
BufSize: Integer; // or DWORD;
Entries: Integer; // or DWORD;
begin
FillChar(EntireNetwork, SizeOf(EntireNetwork), 0);
with EntireNetwork do
begin
dwScope := 2;
dwDisplayType := 6;
dwUsage := 2;
end;
WNetOpenEnum(RESOURCE_GLOBALNET,
RESOURCETYPE_ANY,
0,
@EntireNetwork,
EnumHandle);
WorkgroupCount := 0;
repeat
Entries := 1;
BufSize := SizeOf(Buf);
WNetEnumResource(EnumHandle,
Entries,
@Buf,
BufSize);
if Entries = 1 then
begin
Inc(WorkgroupCount);
Workgroup[WorkgroupCount] := StrPas(Buf[1].lpRemoteName);
end;
until (Entries <> 1);
WNetCloseEnum(EnumHandle);
end;
Feliratkozás:
Megjegyzések küldése (Atom)
Nincsenek megjegyzések:
Megjegyzés küldése