Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to search for shared folders in a network Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
12-Sep-03
Category
System
Language
Delphi 2.x
Views
115
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			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;


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC