SetLastErrorEx function (winuser.h) - Win32 apps (original) (raw)

Skip to main content

This browser is no longer supported.

Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.

SetLastErrorEx function (winuser.h)

In this article

Sets the last-error code.

Currently, this function is identical to theSetLastError function. The second parameter is ignored.

Syntax

void SetLastErrorEx(
  [in] DWORD dwErrCode,
  [in] DWORD dwType
);

Parameters

[in] dwErrCode

The last-error code for the thread.

[in] dwType

This parameter is ignored.

Return value

None

Remarks

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

Most functions callSetLastError or SetLastErrorEx only when they fail. However, some system functions callSetLastError 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 theGetLastError 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 the application and to ensure that your error code does not conflict with any system-defined error codes.

Requirements

Requirement Value
Minimum supported client Windows XP [desktop apps only]
Minimum supported server Windows Server 2003 [desktop apps only]
Target Platform Windows
Header winuser.h (include Windows.h)
Library User32.lib
DLL User32.dll

See also

Error Handling Functions

GetLastError

Last-Error Code


Feedback

Additional resources

In this article