procedure TForm1.Button1Click(Sender: TObject) ;
var
ComputerName: PChar;
size: DWord;
begin
GetMem(ComputerName,255) ;
size:=255;
// 获取计算机名称
if GetComputerName(ComputerName,size)=False then
begin
MessageBox(Handle, '获取计算机名称失败。' , '错误' , MB_OK+MB_ICONERROR);
FreeMem(ComputerName);
Exit;
end;
Edit1.Text:=ComputerName;
FreeMem(ComputerName) ;
end;