Find out the workgroup name

The question was asked: 6 years 9 months ago   views: 5
0

How to find the workgroup name of the network where the computer is located?
How to find the list of workgroups on your network?

Asked: Max Max 21-06-2012 в 12:18:16

Answers   3

0

Windows start,control panel,system, computer name. In any file Manager (where the discs, there is an icon "network"). Totalcomander, network, entire network, Microsoft Windows NetWork. You will see groups that exist in your mesh IP addresses.

Answered: nik030947 nik030947 21-06-2012 в 12:34:45
so...I'm sorry... put the wrong question... the name of the workgroup need to Delphi. - Леонид Леонид 21-06-2012 в 12:42:52
0
function TForm1.GetNTDomainName: string;
 var hReg: TRegistry;
begin
 hReg := TRegistry.Create;
 hReg.RootKey := HKEY_LOCAL_MACHINE;
 hReg.OpenKey('SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon', false);
 Result := hReg.ReadString('DefaultDomainName');
hReg.CloseKey;
hReg.Destroy;
end;
Answered: teanЫЧ teanЫЧ 21-06-2012 в 13:01:10
0

This code gets the working group and the names of all the computers in it. Displays in TreeViev.

The IP and the computer Name is easier to find. Here is the source code

www.connecter.16mb.com/NET

On the form, treeview1, edit1, button, library WinSock2

To add to the folder with the project library WinSock2. Add to Uses WinSock2.

When you press the button is getting all the computer names

treeview1.Items[0].DeleteChildren;
treeview1.Items[0].Text:=edit1.Text;
FindAllComputers(edit1.Text);

Add Type and Variables

type

 PWkstaInfo = ^TWkstaInfo;
 TWkstaInfo = record
 wki100_platform_id : DWORD;
 wki100_computername : PWideChar;
 wki100_langroup : PWideChar;
 wki100_ver_major : DWORD;
 wki100_ver_minor : DWORD;
end;

 function NetWkstaGetInfo(ServerName: PWideChar; Level: DWORD;
Bufptr: Pointer): DWORD; stdcall; external 'netapi32.dll';

var
 Form1: TForm1;
 Info: PWkstaInfo;
 Error: DWORD;

Obtaining A Slave.Group (Such As Form1.Create)

Error := NetWkstaGetInfo(nil, 100, @Info);
if Error <> 0 then
raise Exception.Create(SysErrorMessage(Error));
Edit1.Text:= info^.wki100_langroup;

Procedure

 procedure FindAllComputers(Workgroup: String);
var
 Computer: array[1..500] of string[25];
 ComputerCount: integer;
 EnumHandle: THandle;
 WorkgroupRS: TNetResource;
 Buf: array[1..500] of TNetResource;
 BufSize: cardinal;
 Entries: cardinal;
 Result: integer;
 i: integer;
Chl:ttreenode;
DelProcValue:string;
begin
 ComputerCount := 0;
 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 );
Repeat
 Entries := 1;
 BufSize := SizeOf( Buf );
 Result := WNetEnumResource( EnumHandle, Entries, @Buf, BufSize );
 If ( Result = NO_ERROR ) and ( Entries = 1 ) then
begin
 Inc( ComputerCount );
 Computer[ComputerCount] := StrPas( Buf[1].lpRemoteName );
end;

 Until ( Entries <> 1 ) or ( Result <> NO_ERROR );
 WNetCloseEnum( EnumHandle );
 for i := 1 to ComputerCount do
begin
 Chl:= form1.TreeView1.Items.AddChild(form1.TreeView1.Items[0],Computer[i]);
chl.ImageIndex:=1;
chl.selectedindex:=1;
DelProcValue:=chl.Text;
delete(DelProcValue,1,2);

end;

end;
Answered: @info @info 21-06-2012 в 14:08:46