Author: Lou Adler How to search for shared folders in a network Answer: You will need a listbox, a radiogroup with 3 radio buttons and of course a button. It takes a while depending on the size of your network. 1 2 procedure TForm1.EnumNetResources(List: TStrings); 3 4 procedure EnumFunc(NetResource: PNetResource); 5 var 6 Enum: THandle; 7 Count, BufferSize: DWORD; 8 Buffer: array[0..16384 div SizeOf(TNetResource)] of TNetResource; 9 i: Integer; 10 begin 11 if WNetOpenEnum(RESOURCE_GLOBALNET, RESOURCETYPE_ANY, 0, NetResource, 12 Enum) = NO_ERROR then 13 try 14 Count := $FFFFFFFF; 15 BufferSize := SizeOf(Buffer); 16 while WNetEnumResource(Enum, Count, @Buffer, BufferSize) = NO_ERROR do 17 for i := 0 to Count - 1 do 18 begin 19 case RadioGroup1.ItemIndex of 20 0: 21 begin {Network Machines} 22 if Buffer[i].dwType = RESOURCETYPE_ANY then 23 List.Add(Buffer[i].lpRemoteName); 24 end; 25 1: 26 begin {Shared Drives} 27 if Buffer[i].dwType = RESOURCETYPE_DISK then 28 List.Add(Buffer[i].lpRemoteName); 29 end; 30 2: 31 begin {Printers} 32 if Buffer[i].dwType = RESOURCETYPE_PRINT then 33 List.Add(Buffer[i].lpRemoteName); 34 end; 35 end; 36 if (Buffer[i].dwUsage and RESOURCEUSAGE_CONTAINER) > 0 then 37 EnumFunc(@Buffer[i]) 38 end; 39 finally 40 WNetCloseEnum(Enum); 41 end; 42 end; 43 44 begin 45 EnumFunc(nil); 46 end; 47 48 procedure TForm1.Button1Click(Sender: TObject); 49 begin 50 Listbox1.Clear; 51 Screen.Cursor := crHourglass; 52 EnumNetResources(ListBox1.Items); 53 Screen.Cursor := crDefault; 54 end;