Home > error > Display an Error Message for an OS Error Code

Display an Error Message for an OS Error Code

Delphi’s SysErrorMessage function converts OS error codes into a string – an error message string that corresponds to the specified OS error code..

GetLastError returns the last error reported by an operating system API call.

Note: calling getLastError resets the operating system error state – do not call it two times “in a row” – the second call will clear the “first” error.

Convert the OS Error Code into a User Friendly Message

Here’s a quick example – trying to delete a non existing folder. RemoveDir deletes an existing empty directory. The return value is true if a new directory was successfully deleted, false if an error occurred. Read GetLastError to find out why an error occurred.

RemoveDir(‘c:\NoSuchFolder’) ;

ShowMessage(‘System Error Message: ‘+ SysErrorMessage(GetLastError)) ;

Categories: error Tags: ,
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: