Delphi Xe.
in delphi help: “…Calling this function usually resets the operating system error state…”
How to reset a current error on 0? I.e. that GetLastError=0
Example:
Try
// There is an error
except
showmessage(inttostr(getlasterror)); // Ok, getlasterror<>0
end;
....
// no errors
....
// How to reset a current error on 0?
showmessage(inttostr(getlasterror)); // Again will be <> 0
You should only be calling
GetLastErrorwhen there has actually been an error. Some Windows API functions will reset the error to 0 on success, some won’t. Either way, you should only interrogate the error state when you need to know the most recent error.Note that there is a
SetLastErrormethod as well, but that doesn’t help you; if you set the last error to 0, then of courseGetLastErrorwill return 0.