Get dll error description

Syntax

s.dllerror([message] [dll] [errorcode])

 

Parameters

s - str variable.

message - string to prepend. Default: "".

dll - where to search for error description. Default: "". Possible values:

"" or omitted search in Windows system dlls (mostly used).
a dll filename or full path search in that dll.
"C" get C run-time library (MSVCRT) error description.

errorcode - numeric error code. If omitted or 0, calls GetLastError; it gets error code set by the last called dll function (or explicitly with SetLastError) in this thread.

 

Remarks

Many Windows dll functions and other functions set an error code (an integer number) when they fail. If you read function documentation, often it says "If the function fails ... call GetLastError.". Some other functions instead return a nonzero value when they fail, and it usually is an error code. Many error codes are known and have text descriptions. This function gets the description (calls FormatMessage). If description not found, gets "".

 

Example

if CopyFile("nosuchfile" "tonosuchfile" 1) = 0
	str s.dllerror("Last dll error: ")
	out s
 Output:
 Last dll error: The system cannot find the file specified.