如何获得计算机名字,不要ip,多谢!

解决方案 »

  1.   

    ComputerName : string;
    function TDmSys.GetComputerNameA: String;
    var
      CName: string;
      Size: DWord;
    begin
      Size := 256;
      SetLength(CName,Size);
      if GetComputerName(Pchar(CName),Size) then
        Result := CName
      else
        Result := '';
    end;
    function TDmSys.GetComputerNameA: String;
    var
      CName: string;
      Size: DWord;
    begin
      Size := 256;
      SetLength(CName,Size);
      if GetComputerName(Pchar(CName),Size) then
        Result := CName
      else
        Result := '';
    end;
    然後自己賦值取計算機名就是了!!