While testing my apps on various devices I discovered OEMs remove messagetables from resources. This is really annoying issue as I have to scan documentation for error codes returned by GetLastError. So I created my own replacement. You can grab it from
here. This one can return not only names of the errors (ie.
ERROR_DIRECT_ACCESS_HANDLE) but also short descriptions (
ERROR_DIRECT_ACCESS_HANDLE Attempt to use a file handle to an open disk partition for an operation other than raw disk I/O.)
Usage- Copy win_err_lib.dll to the path your application will be launched from.
- Copy win_err.pas to suitable path and add win_err to the uses list of your unit(s).
- Whenever you need to check and display (or log) occurred Windows error, do it like this:
le := GetLastError; //save for further processing, optional
ShowMeTheError( GetLastErrorStr( le ) );
[/list]
ConfigurationThere are two options affecting returned values and both are set up as conditional compiler directives, so you'll need to re-compile the library if you want the changes to be applied.
{$DEFINE SUCCESS_EMPTY} //this is default
WriteLn( GetLastErrorStr( 0 ) ); // <returns empty string>
{.$DEFINE SUCCESS_EMPTY}
WriteLn( GetLastErrorStr( 0 ) );// ERROR_SUCCESS
{.$DEFINE ERROR_DESCRIPTION} // this is default
WriteLn( GetLastErrorStr( 68 ) ); // ERROR_TOO_MANY_SESS
{$DEFINE ERROR_DESCRIPTION}
WriteLn( GetLastErrorStr( 68 ) ); // ERROR_TOO_MANY_SESS The network BIOS session limit was exceeded.
RemarksAll error strings are compiled as resources into the library. The DLL has been compiled with -WR switch, so it should be safe to use the library among others created with FPC.
I included virtually all error messages for Windows CE 5.0 without COM-specific. The total number is over 1,800.
Hope this will help you debugging your apps.
EDIT (March 17th, 07:10 GMT)
Those who downloaded the library before this edit DateTime (
), please re-download. While testing with different compilers I messed up handle types and uploaded wrong version. Now it works correctly on WinCE.