WindowsErrorText - Get a human readable error message for an O/S error code

Top  Previous  Next

Syntax

 

<cErrorInformation> := WindowsErrorText( [<nLongErrorCode>] )

 

Parameters

 

<nLongErrorCode>

 

Error code (a LONG value) to retrieve a human readable error message for. If this parameter is not passed, the API function GetLastError() is called and the error message for the returned error code is retrieved.

 

Return value

 

A string containing the human readable Windows error message for the error code <nLongErrorCode>.

 

Description

 

WindowsErrorText queries the O/S for a human error message for an error code returned by a previous function call using FormatMessage(). If no error code is passed, WindowsErrorText calls the API function GetLastError() to retrieve the code of the last O/S error that occurred in the current thread.

 

Classification

 

Core

 

Category

 

Error Handling

 

Quick Info

 

Library: cckptcor.lib / cckptcor.dll

 

Example

 

 

#INCLUDE "CockpitCoreLibs.ch"

 

FUNCTION Main

 

LOCAL handle

 

* Try to open a file that does not exist

handle := FOpen("DefinitelyNotThere")

 

* Problems encountered?

IF handle == -1

 

  * Display the error and terminate the program

  SysError("Dang: "+WindowsErrorText())

 

ENDIF

 

RETURN NIL