|
Interop::GetLastError
The Interop::GetLastError function returns the result of
the GetLastError
Windows API function as returned after the last call to Call or Call2.
Syntax
[number] GetLastError();
Parameters
None.
Return Value
A number representing the last error value recorded by the
Windows API. Its meaning depends on the last function from the
Windows API that was called. Remember that the value returned by
this function only has a meaning for the last function called by
either Call or Call2.
This function typically fails for the following reason:
- The Interop object refers to a window that has been
destroyed.
Remarks
Use this function instead of Interop.Call("Kernel32.dll",
"GetLastError"). Because Messenger Plus! performs several
actions when Call is called, the LastError value is modified before the actual call
is made.
Example
The following code displays a readable error message based on
the last error code registered in the Windows API. Remember that
these codes are not set by every function in Windows, you should
check out the MSDN documentation for more information about the
errors returned by the functions you are using.
function TraceWin32Error()
{
var LastError = Interop.GetLastError();
if(LastError != 0)
{
var MsgBuffer = Interop.Allocate(1024);
Interop.Call("Kernel32", "FormatMessageW", 0x1000, 0,
LastError, 0, MsgBuffer, 1024, 0);
Debug.Trace(MsgBuffer.ReadString(0));
MsgBuffer.Size = 0; //Release the allocated memory now
}
}
Function Information
| Object |
Interop |
| Availability |
Messenger Plus! Live 4.00 |
See Also
Interop Object, Windows
API GetLastError.
|