windows_programming_notes.nbk: Home | Index | Next Page: SetScrollInfo | Previous Page: SetFocus


 SetLastError

Sets the last-error code for the calling thread.

    void WINAPI SetLastError(
      __in  DWORD dwErrCode
    );

Parameters

Return Value

This function does not return a value.

Remarks

The last-error code is kept in thread local storage so that multiple threads do not overwrite each other's values.

This function is intended primarily for use by dynamic-link libraries (DLL). A DLL can provide the applications that are using it with additional diagnostic information by calling this function after an error occurs. Most functions call SetLastError or SetLastErrorEx only when they fail. However, some system functions call SetLastError or SetLastErrorEx under conditions of success; those cases are noted in each function's documentation.

Applications can optionally retrieve the value set by this function by using the GetLastError function immediately after a function fails.

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 indicate that the error code has been defined by your application and to ensure that your error code does not conflict with any system-defined error codes.

Requirements


windows_programming_notes.nbk: Home | Index | Next Page: SetScrollInfo | Previous Page: SetFocus


Notebook exported on Monday, 7 July 2008, 18:56:50 PM Eastern Daylight Time