Functions Delphi

function GetLastError : Integer;


Description
The GetLastError function returns the value of the last failed Windows API call.

It is useful for many SysUtils routines, such as illustrated in the example.

Related commands
IOResult Holds the return code of the last I/O operation

Example code : Try to delete a non-existant file and report the error code
begin
if DeleteFile('CanDeletMe.txt')
then ShowMessage('File deleted OK')
else ShowMessage('File not deleted, error code = '+
IntToStr(GetLastError));
end;

Show full unit code
File not deleted, error code = 2