Sets the last-error code for the calling thread.
VOID SetLastError(
DWORD dwErrCode
VOID RtSetLastError(
DWORD dwErrCode
);
Parameters
dwErrCode
- Specifies the last-error code for the thread.
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.
Return Values
None.
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, SetLastError and RtSetLastError are synonyms.
- This function operates in the real-time portion of your application.
See Also
GetLastError, iwin32 API, iwin32 Overview