procedure EnumNetResources(List: TStrings);
procedure EnumFunc(NetResource: PNetResource);
var
Enum: THandle;
Count, BufferSize: DWORD;
Buffer: array[0..16384 div SizeOf(TNetResource)] of TNetResource;
i: Integer;
tstr: string;
begin
if WNetOpenEnum(RESOURCE_GLOBALNET, RESOURCETYPE_ANY, 0, NetResource,
Enum) = NO_ERROR then
try
Count := $FFFFFFFF;
BufferSize := SizeOf(Buffer);
while WNetEnumResource(Enum, Count, @Buffer, BufferSize) = NO_ERROR do
for i := 0 to Count - 1 do
begin
if Buffer[i].dwDisplayType = RESOURCEDISPLAYTYPE_SERVER then
begin
tstr := Buffer[i].lpRemoteName;
delete(tstr,1,2);
List.Add(tstr);
end;
if (Buffer[i].dwUsage and RESOURCEUSAGE_CONTAINER) > 0 then
EnumFunc(@Buffer[i])
end;
finally
WNetCloseEnum(Enum);
end;
end;
begin
List.Clear;
EnumFunc(nil);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
EnumNetResources(ListBox1.Items);
end;