Solved

Getting network information

Posted on 1998-11-18
6
341 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
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…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

734 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