Solved

Getting network information

Posted on 1998-11-18
6
336 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

706 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now