procedure TForm1.Button1Click(Sender: TObject);
var
CName: array [0..Max_ComputerName_Length] of Char;
CNLength: DWORD;
begin
CNLength := Max_ComputerName_Length+1;
if GetComputerName(@CName[0], CNLength) then
Label1.Caption := CName
else
Label1.Caption := format('Get Computer name failed, error: %d.',[GetLastError]);
end;