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 Find all computers in a workgroup. 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
08-Sep-03
Category
Internet / Web
Language
Delphi 4.x
Views
235
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Erwin Molendijk 

Finding all computers in a workgroup. 

Answer:

1   var
2     Computer: array[1..500] of string[25];
3     ComputerCount: Integer;
4   
5   procedure FindAllComputers(Workgroup: string);
6   var
7     EnumHandle: THandle;
8     WorkgroupRS: TNetResource;
9     Buf: array[1..500] of TNetResource;
10    BufSize: Integer;
11    Entries: Integer;
12    Result: Integer;
13  
14  begin
15    ComputerCount := 0;
16  
17    Workgroup := Workgroup + #0;
18  
19    FillChar(WorkgroupRS, SizeOf(WorkgroupRS), 0);
20    with WorkgroupRS do
21    begin
22      dwScope := 2;
23      dwType := 3;
24      dwDisplayType := 1;
25      dwUsage := 2;
26      lpRemoteName := @Workgroup[1];
27    end;
28  
29    WNetOpenEnum(RESOURCE_GLOBALNET,
30      RESOURCETYPE_ANY,
31      0,
32      @WorkgroupRS,
33      EnumHandle);
34  
35    repeat
36      Entries := 1;
37      BufSize := SizeOf(Buf);
38  
39      Result :=
40        WNetEnumResource(EnumHandle,
41        Entries,
42        @Buf,
43        BufSize);
44      if (Result = NO_ERROR) and (Entries = 1) then
45      begin
46        Inc(ComputerCount);
47        Computer[ComputerCount] := StrPas(Buf[1].lpRemoteName);
48      end;
49    until (Entries <> 1) or (Result <> NO_ERROR);
50  
51    WNetCloseEnum(EnumHandle);
52  end; { Find All Computers }


			
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