Delphi7获取本机名称的代码

function GetComputerNameEx: string; //获取本机名称
var
  ComputerName: PChar;
  size: DWord;
begin
  GetMem(ComputerName, 255);
  size := 255;
      //   获取计算机名称
  if GetComputerName(ComputerName, size) = False then
  begin
    result := '';
    FreeMem(ComputerName);
    Exit;
  end;
  result := ComputerName;
  FreeMem(ComputerName);
end;

 

你可能感兴趣的:(Delphi)