Einzelnen Beitrag anzeigen

Benutzerbild von jaenicke
jaenicke

Registriert seit: 10. Jun 2003
Ort: Berlin
9.648 Beiträge
 
Delphi 11 Alexandria
 
#9

AW: Set hostname - can't write to registry

  Alt 6. Apr 2012, 17:37
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));
Sebastian Jänicke
AppCentral
  Mit Zitat antworten Zitat