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; // 或DWORD;
Entries: Integer; // 或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;
|