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 MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Any way to grab machine name? 1

Status
Not open for further replies.

Jonah86

Programmer
Dec 11, 2003
152
US
I'm having an issue trying to track a group of users who all log in with the same user name. I'm just trying to put a new record in the DB with the changes they make. Normally I'd just use their user name, but obviously can't.

Is there any way to get the computer name from windows and plug it into my query?
 
Sorry, forgot to mention I'm using Delphi 7 and the users are using Win2k.

Is there a way to edit posts here?

Thanks for the help.
 
This is what I use to get the computer name. I can't remember where I got the code from.
Code:
//------------------------------------------------------------------------------
function ComputerName: string;
//------------------------------------------------------------------------------
var
  ComputerNameLength: DWord;
begin
  ComputerNameLength := MAX_COMPUTERNAME_LENGTH;
  SetLength(Result, MAX_COMPUTERNAME_LENGTH);
  if GetComputerName ( pchar(result), ComputerNameLength ) then
    SetLength ( result, ComputerNameLength )
  else
    result := ''
end;

Andrew
Hampshire, UK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top