procedure TForm1.Button1Click(Sender: Tobject);
var
ComputerName: array[0..MAX_COMPUTERNAME_LENGTH+1] of char;
Size: dword;
begin
{initialize the computer name size variable}
Size := MAX_COMPUTERNAME_LENGTH+1;
{retrieve the computer name}
if GetComputerName(ComputerName, Size) then
Edit1.Text := StrPas(Computername)
else Showmessage('Computer Name Not Found');
end;
procedure TForm1.Button2Click(Sender: TObject);
var
ComputerName: array[0..MAX_COMPUTERNAME_LENGTH+1] of char; // holds the name
begin
{copy the specified name to the ComputerName buffer}
StrPCopy(ComputerName, Edit1.Text);
{set the computer name}
if SetComputerName(ComputerName) then
ShowMessage('Computer Name Reset Setting will be used at next startup')
else ShowMessage('Computer Name Not Reset');
end;
The Tomes of Delphi 3: Win32 Core API Help File by Larry Diehl