Correct usage of GetLastError and FormatMessage in Delphi.
ShowMessage(SysErrorMessage(GetLastError))) 
Taken from here.