You have to ensure, that no other
API function is called after the one you want to check against errors. Otherwise the error state is overwritten before you check it...
But here you call ShowMessage for the result of SetComputerName and fetch the error after this. So you won't get an error unless ShowMessage fails...
What about this way?
Delphi-Quellcode:
if SetComputerName('TTX') then
ShowMessage('Success')
else
ShowMessage(SysErrorMessage(GetLastError));