Mega Code Archive

 
Categories / Delphi / VCL
 

Getting a string representation of a windows error code

Question: How can I get a string representation of the last Windows error value returned by the Windows GetLastError? Answer: Use the RTL function SysErrorMessage(GetLastError). Example: procedure TForm1.Button1Click(Sender: TObject); begin {Cause a Windows system error message to be logged} ShowMessage(IntToStr(lStrLen(nil))); ShowMessage(SysErrorMessage(GetLastError)); end;