Author: Erwin Molendijk Enumerating workgroups on your LAN. Answer: 1 { This code is a copy-paste from a working application. 2 } 3 4 var 5 WorkgroupCount: Integer; 6 Workgroup: array[1..500] of string[25]; 7 8 procedure FindAllWorkgroups; 9 var 10 EnumHandle: THandle; 11 EntireNetwork: TNetResource; 12 Buf: array[1..500] of TNetResource; 13 BufSize: Integer; // or DWORD; 14 Entries: Integer; // or DWORD; 15 16 begin 17 FillChar(EntireNetwork, SizeOf(EntireNetwork), 0); 18 with EntireNetwork do 19 begin 20 dwScope := 2; 21 dwDisplayType := 6; 22 dwUsage := 2; 23 end; 24 25 WNetOpenEnum(RESOURCE_GLOBALNET, 26 RESOURCETYPE_ANY, 27 0, 28 @EntireNetwork, 29 EnumHandle); 30 31 WorkgroupCount := 0; 32 repeat 33 Entries := 1; 34 BufSize := SizeOf(Buf); 35 36 WNetEnumResource(EnumHandle, 37 Entries, 38 @Buf, 39 BufSize); 40 if Entries = 1 then 41 begin 42 Inc(WorkgroupCount); 43 Workgroup[WorkgroupCount] := StrPas(Buf[1].lpRemoteName); 44 end; 45 until (Entries <> 1); 46 47 WNetCloseEnum(EnumHandle); 48 end;