Movatterモバイル変換


[0]ホーム

URL:


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.

Download Microsoft EdgeMore info about Internet Explorer and Microsoft Edge
Table of contentsExit focus mode

SetLastError function (errhandlingapi.h)

  • 2024-02-22
Feedback

In this article

Sets the last-error code for the calling thread.

Syntax

void SetLastError(  [in] DWORD dwErrCode);

Parameters

[in] dwErrCode

The last-error code for the thread.

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

Requirements

RequirementValue
Minimum supported clientWindows XP [desktop apps | UWP apps]
Minimum supported serverWindows Server 2003 [desktop apps | UWP apps]
Target PlatformWindows
Headererrhandlingapi.h (include Windows.h)
LibraryKernel32.lib
DLLKernel32.dll

See also

Error Handling Functions

GetLastError

Last-Error Code

SetLastErrorEx

Vertdll APIs available in VBS enclaves


Feedback

Was this page helpful?

YesNo

In this article

Was this page helpful?

YesNo