please dont rip this site Prev Next

GetLastError info  Overview  Group

The GetLastError function returns the calling threadís last-error code value. The last-error code is maintained on a per-thread basis. Multiple threads do not overwrite each otherís last-error code.

DWORD GetLastError(VOID)


This function has no parameters.

Return Values

The return value is the calling threadís last-error code value. Functions set this value by calling the SetLastError function. The Return Value section of each reference page notes the conditions under which the function sets the last-error code.


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.

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 SetLastError under 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 operating system.

To obtain an error string for operating system error codes, use the FormatMessage function. For a complete list of error codes, see Error Codes or the SDK header file WINERROR.H.

See Also

FormatMessage, SetLastError, SetLastErrorEx 


file: /Techref/os/win/api/win32/func/src/f33_15.htm, 6KB, , updated: 2001/6/26 11:28, local time: 2024/6/23 01:34,

 ©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it! / MAKE!

<A HREF=""> GetLastError</A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type a nice message (short messages are blocked as spam) in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.

Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?


Welcome to!


Welcome to!