Returns the current thread's last exception code.
DWORD GetLastError(VOID)
DWORD RtGetLastError(VOID)
Parameters
None.
Remarks
- iWin32 functions set the thread's last error code based on these function states:
- Success: Some functions set the error code (call SetLastError) upon success, which can overwrite an error code set by the most recently failed function. Therefore, when a function returns a value that indicates an error code is available, call GetLastError immediately.
- Failure: Most functions set the error code (call SetLastError) upon failure. Typical return values include , NULL, 0xFFFFFFFF, or -1.
- The last-error code is kept in thread local storage so that multiple threads do not overwrite each other's values.
- Applications can optionally retrieve the error code by calling GetLastError to find why a function failed.
- Error codes are 32-bit values:
- Bit 31 is the most significant bit.
- Bit 29 is reserved for application-defined error codes; no system error code has this bit set. If you define an error code for your application, set this bit to one. This setting indicates that an application defined the error code, and avoids conflict between your error and any system-defined error codes.
Note: This call and the INtime GetLastRtError call share the same storage for the thread's last-error value. The difference is that this call returns all 32 bits of the status value whereas the INtime call returns only 16 bits of the value.
Return Values
Returns the calling thread's last-error code value. This value may be explicitly set by calling SetLastError.
Code values are the same as returned by WIndows calls.
Requirements
Versions |
Defined in |
Include |
Link to |
INtime 3.0 |
intime/rt/include/iwin32.h intime/rt/include/winbase.h |
iwin32.h windows.h |
iwin32.lib |
Note
- In the iwin32 API, GetLastError and RtGetLastError are synonyms.
- This function operates in the real-time portion of your application.
See Also