--- ---

Here are two routines, one to read the computer name and the other to set it.

    function GetPCName: string;
    var
      buffer: array[0..MAX_COMPUTERNAME_LENGTH + 1] of Char;
      Size: Cardinal;
    begin
      Size := MAX_COMPUTERNAME_LENGTH + 1;
      Windows.GetComputerName(@buffer, Size);
      Result := StrPas(buffer);
    end;

    function SetPCName(AName: string): Boolean;
    var
      PCName: array[0..MAX_COMPUTERNAME_LENGTH + 1] of Char;
      Size: Cardinal;
    begin
      StrPCopy(PCName, AName);
      Result := Windows.SetComputerName(PCName);
    end;

SetPCName will fail unless the current user has administrator rights.