Solved

Getting network information

Posted on 1998-11-18
6
340 Views
Last Modified: 2010-04-04
My Delphi program has to run in a Microsoft Win95 network and needs the following data: user name, computer name and workgroup name. How can I retrieve this info using Delphi code?
0
Comment
Question by:sandman_br
6 Comments
 
LVL 1

Accepted Solution

by:
jecksom earned 100 total points
ID: 1347239
hi Sandman!

NetQueryDisplayInformation

Jecksom

0
 
LVL 1

Expert Comment

by:jecksom
ID: 1347240
getcomputername and getusername , also could give part of information you looking for
0
 
LVL 1

Expert Comment

by:jecksom
ID: 1347241
procedure TForm1.FormCreate(Sender: TObject);
 var
     compbuf,userbuf: array [0..16] of Char;
     compsize,usersize: DWORD;
 begin
     compsize := 16;
     usersize := 16;
     GetComputerName(compbuf, compSize);
     GetUserName(userbuf, userSize);
     showmessage(userbuf+' '+compbuf);
 end;

0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 4

Expert Comment

by:BoRiS
ID: 1347242
jecksom

The NetQueryDsplayInformation is a Windows Nt API only it will not return on Win 95 however u are correct in the get computer/username API

Sandman_br

Here is some code to get the username and Computername

procedure TForm1.FormCreate(Sender: TObject);
var
 NameBuf, NameBuf2: array[0..80] of Char;
 SizeBuf, SizeBuf2: LongWord;
begin
  SizeBuf := Sizeof(NameBuf);
   GetUserName(NameBuf, SizeBuf);
    Edit1.Text := NameBuf;
     SizeBuf2 := Sizeof(NameBuf2);
      GetComputerName(NameBuf2, SizeBuf2);
       Edit2.Text := NameBuf2;

end;

The Workgroup I think needs to be read from the registry...

it sits under the path HKEY_LOCAL_MACHINE\system\CurrentControlSet\Services\VxD\VNETSUP\
the string to read is Workgroup...

Later
BoRiS


0
 
LVL 5

Expert Comment

by:ronit051397
ID: 1347243
C sources for network info:    http://www.mvps.org/win32/
0
 

Author Comment

by:sandman_br
ID: 1347244
Thanks a lot! I had tried getusername () and getcomputername () at first, but
only getusername () worked... maybe because I was trying to reuse the buffer
and size variables I passed for the first call in the second call. It only
worked with separate variables for each call, as you suggested... but now it's fine. :)
As for the workgroup name, BoRiS's suggestion worked plain great. Kudos to ronit
for the cool link. Thanx again, guys!

C ya,
Sandman
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question