function GetMachine: string;
var
n: dword;
buf: pchar;
const
rkMachine = {HKEY_LOCAL_MACHINE}
'\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName';
rvMachine = 'ComputerName';
begin
n := 255;
buf := stralloc(n);
GetComputerName(buf, n);
result := buf;
strdispose(buf);
with TRegistry.Create do
begin
rootkey := HKEY_LOCAL_MACHINE;
if OpenKeyReadOnly(rkMachine) then
begin
if ValueExists(rvMachine) then
result := ReadString(rvMachine);
closekey;
end;
free;
end;
end;