unit Main;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls;

const cnMaxLen = 254;

type
  TFMain = class(TForm)
    Panel1: TPanel;
    Button1: TButton;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private

  public
    function DajNazweKomputera() : String;
  end;

var
  FMain: TFMain;

implementation

{$R *.dfm}

procedure TFMain.Button1Click(Sender: TObject);
begin
	Close();
end;

procedure TFMain.Button2Click(Sender: TObject);
begin
	ShowMessage(DajNazweKomputera());
end;

function TFMain.DajNazweKomputera() : String;
var
	sCompName: String;
   dwCompNameLen: DWord;

begin
	dwCompNameLen := cnMaxLen - 1;
   SetLength(sCompName, cnMaxLen);
   GetComputerName(Pchar(sCompName), dwCompNameLen);
   SetLength(sCompName, dwCompNameLen);

   Result := sCompName;

   if dwCompNameLen = cnMaxLen-1 then
   begin
      Result := '';
   end
   else begin
      Result := UpperCase(Result[1]) + LowerCase(Copy(Result,2,Length(Result)-1));
   end;
end;

end.

