Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Local Machine Name 2

Status
Not open for further replies.

xartas

Programmer
Aug 20, 2001
26
ES
Hi, i'm writing a program that needs the local machine name of the machine where it's running. Which function should i use to read this parameter?

Best regards.
 
Try
Wnetgetconnection, Wnetgetuser.

or one of the others in this group.

The local name is held in the lplocalname property of the netresource structure.

Delphi Help will jump to the relevent API stuff if you do an F1 on wnetgetuser

Steve
 
You can also just look it up in the registery.
Everyone has a right to my opinion.
E-mail me at cwcon@programmer.net
Be a nice guy 'n press that little ol' button
VVV---(this one) for me ;-)
 
You first need to Create 2 Variables

NameSize : DWORD;
ComputerName : PChar;

Then use this code to read the name and place it in a label

ComputerName := #0;
NameSize := MAX_COMPUTERNAME_LENGTH + 1;
try
GetMem(ComputerName, NameSize);
Windows.GetComputerName(ComputerName, NameSize);
Label1.Caption:= StrPas(ComputerName);
finally
FreeMem(ComputerName);
end;

You could create another Variable (String this time) and then assign the value to that instead of the Label Caption.

Kind Regards, Paul Benn

**** Never Giveup, keep trying, the answer is out there!!! ****
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top