|This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.|
This function returns the calling thread's last-error code value. A remote application interface (RAPI) version of this function exists, and it is named CeGetLastError.
DWORD GetLastError( void );
The calling thread's last-error code value indicates success. Functions set this value by calling the SetLastErrorfunction. The Return Valuesection of each reference page notes the conditions under which the function sets the last-error code.
You should call the GetLastErrorfunction 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.
Most functions in the Win32 API that set the thread's last error code value set it when they fail; a few functions set it when they succeed. Function failure is typically indicated by a return value error code such as FALSE, NULL, 0xFFFFFFFF, or –1. Some functions call SetLastErrorunder conditions of success; those cases are noted in each function's reference page.
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 are defining an error code for your application, set this bit to one. That indicates that the error code has been defined by an application, and ensures that your error code does not conflict with any error codes defined by the system.
|Runs On||Versions||Defined in||Include||Link to|
|Windows CE OS||1.0 and later||Winbase.h||Coredll.lib, Nk.lib|
Note This API is part of the complete Windows CE OS package as provided by Microsoft. The functionality of a particular platform is determined by the original equipment manufacturer (OEM) and some devices may not support this API.