Mega Code Archive

 
Categories / Delphi / System
 

How do I determine the Computer Name

Title: How do I determine the Computer Name I've forgotten where I got this code from but it seems to work okay. 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;