Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Getting network information

Posted on 1998-11-18
6
Medium Priority
?
344 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 400 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

610 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