Returns the last error code of a Win32 function.
% = Err.LastDLLError
The LastDLLError property invokes the GetLastError API function to obtain the calling thread's last-error code value. Note that the LastDLLError is read-only.
When an error occurs, most Win32 functions return an error code, usually False, Null, 0xFFFFFFFF, or -1. Many functions also set an internal error code called the last-error code. When a function succeeds, the last-error code is not reset. The error code is maintained separately for each running thread; an error in one thread does not overwrite the last-error code in another thread. An application can retrieve the last-error code by using the GetLastError function; the error code may tell more about what actually occurred to make the function fail.
You should call the GetLastError function immediately when a function's return value indicates that such a call will return useful data. That is because some functions call SetLastError(0) when they succeed, wiping out the error code set by the most recently failed function.
Whenever the failure code is returned, the GFA-BASIC 32 application should immediately check the LastDLLError property. No exception is raised when the LastDLLError property is set.
To obtain an error string for system error codes, use the SysErr$ function and pas the value returned by LastDLLError.
' The following lines behave identically
Print SysErr(Err.LastDllError)
Print SysErr(GetLastError())
Some (older) VB documentation wrongly suggest that LastDLLError contains the return value of the last invoked Win32 API function. This is untrue both in VB and GFA-BASIC 32.
{Created by Sjouke Hamstra; Last updated: 11/10/2014 by James Gaite}