Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Server Network info

Status
Not open for further replies.

SlimRoberts

Programmer
Feb 12, 2001
2
IE
I need to get a list of all clients attached to a server.
The ideal would be a small application running on the server showing a list of clients loged on and the IP address and computer name. Any one got any code samples to do this.
Many thanks
Slim
 
Hi,

I'm trying to resolve the same question. On my search i found some code that works. It's not exactly what i want but it is a start. If i figured it out i will send you the exact code.
I'm giving you the complete code the only thing you have to is to put a Tbutton and a Tmemo on the form and replace the complete code with the one beneath. The thing i donn't like is the fact that you have to fill in the workgroup. So the next week i will solve the rest of the puzzle (i hope :) ).

Steph

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;

type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

function FindAllComputers(Workgroup : String):string;

var
Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
var
sList: String;
begin
sList := FindAllComputers('Fill in your workgroup');
Memo1.Lines.Add(sList);
end;

function FindAllComputers(Workgroup : String):string;
Var
EnumHandle : THandle;
WorkgroupRS : TNetResource;
Buf : Array[1..500] of TNetResource;
BufSize : cardinal;
Entries : cardinal;
Res : Integer;
Computer : Tstringlist;
begin
Workgroup := Workgroup + #0;
FillChar(WorkgroupRS, SizeOf(WorkgroupRS) , 0);
With WorkgroupRS do begin
dwScope := 2;
dwType := 3;
dwDisplayType := 1;
dwUsage := 2;
lpRemoteName := @Workgroup[1];
end;
WNetOpenEnum( RESOURCE_GLOBALNET,
RESOURCETYPE_ANY,
0,
@WorkgroupRS,
EnumHandle );
computer:=tstringlist.create;
Repeat
Entries := 1;
BufSize := SizeOf(Buf);
Res :=
WNetEnumResource(EnumHandle, Entries, @Buf, BufSize);
If (Res = NO_ERROR) and (Entries = 1) then
begin
computer.add(StrPas(Buf[1].lpRemoteName));
end;
Until (Entries <> 1) or (Res <> NO_ERROR);
WNetCloseEnum( EnumHandle );
result:=computer.text;
computer.free;
end; { Find All Computers }

end.
 
Many thanks getting the workgroup/domain is easy let me konw if you need it
Slim
 
hi,

Yes, if you want to put it in this thread. Its available for everybody.

Steph
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top