René's URL Explorer Experiment


Title: SetLastError function (errhandlingapi.h) - Win32 apps | Microsoft Learn

Open Graph Title: SetLastError function (errhandlingapi.h) - Win32 apps

Description: Sets the last-error code for the calling thread.

Open Graph Description: Sets the last-error code for the calling thread.

Opengraph URL: https://learn.microsoft.com/en-us/windows/win32/api/errhandlingapi/nf-errhandlingapi-setlasterror

X: @MicrosoftLearn

direct link

Domain: learn.microsoft.com

color-schemelight dark
twitter:cardsummary_large_image
og:typewebsite
og:image:altMicrosoft Learn
og:imagehttps://learn.microsoft.com/en-us/media/open-graph-image.png
platform_id00222883-5f60-11ec-4ded-a18ed6242384
scopeWindows,Desktop
localeen-us
uhfHeaderIdMSDocsHeader-WinDevCenter
page_typeconceptual
adobe-targettrue
breadcrumb_path/windows/desktop/api/breadcrumb/toc.json
ms.servicewindows-api-desktop-tech
ms.subservicesdk-api-reference
ms.topicreference
ms.authorkbridge
authorkarl-bridge-microsoft
feedback_systemStandard
feedback_product_urlhttps://www.microsoft.com/en-us/windowsinsider/feedbackhub/fb
feedback_help_link_urlhttps://learn.microsoft.com/answers/tags/224/windows-api-win32/
feedback_help_link_typeget-help-at-qna
UIDNF:errhandlingapi.SetLastError
old-locationbase\setlasterror.htm
tech.rootDebug
ms.assetidd9da833f-36ca-4046-8d2f-cd4449dd3c63
ms.date2024-02-02T00:00:00Z
ms.keywordsSetLastError, SetLastError function, _win32_setlasterror, base.setlasterror, errhandlingapi/SetLastError
req.headererrhandlingapi.h
req.include-headerWindows.h
req.target-typeWindows
req.target-min-winverclntWindows XP [desktop apps \| UWP apps]
req.target-min-winversvrWindows Server 2003 [desktop apps \| UWP apps]
req.libKernel32.lib
req.dllKernel32.dll
targetosWindows
ms.custom19H1
TopicTypekbSyntax
APITypeDllExport
APILocationvertdll.dll
APINameSetLastError
document_idfc45bc4c-8278-02ba-0f4c-1285eab5ac4b
document_version_independent_idf7164bb0-c7fe-23ee-1386-39870d5b207d
updated_at2025-08-27T22:00:00Z
original_content_git_urlhttps://cpubwin.visualstudio.com/DefaultCollection/win32/_git/sdk-api-build?path=/sdk-api-src/content/errhandlingapi/nf-errhandlingapi-setlasterror.md&version=GBlive&_a=contents
gitcommithttps://cpubwin.visualstudio.com/DefaultCollection/win32/_git/sdk-api-build/commit/0bbc807636f66bcedbaa95e8d0b17a0152e6ef70?path=/sdk-api-src/content/errhandlingapi/nf-errhandlingapi-setlasterror.md&_a=contents
git_commit_id0bbc807636f66bcedbaa95e8d0b17a0152e6ef70
site_nameDocs
depot_nameMSDN.sdk-api-build
schemaConceptual
toc_reltoc.json
pdf_url_templatehttps://learn.microsoft.com/pdfstore/en-us/MSDN.sdk-api-build/{branchName}{pdfName}
search.mshattr.devlangc++
word_count212
asset_iderrhandlingapi/nf-errhandlingapi-setlasterror
item_typeContent
source_pathsdk-api-src/content/errhandlingapi/nf-errhandlingapi-setlasterror.md
previous_tlsh_hash6B646021E00E5F11CEC3D90919D1F29EB6E5C4D07954ABF431299A92D3922DB32F585EF6914BAB42139321232165984FA4C4D76A803B423770542D8C5ABE3CB6A0DDA2796C
github_feedback_content_git_urlhttps://github.com/MicrosoftDocs/sdk-api/blob/docs/sdk-api-src/content/errhandlingapi/nf-errhandlingapi-setlasterror.md
markdown_urlhttps://learn.microsoft.com/en-us/windows/win32/api/errhandlingapi/nf-errhandlingapi-setlasterror?accept=text/markdown
cmProductshttps://authoring-docs-microsoft.poolparty.biz/devrel/bcbcbad5-4208-4783-8035-8481272c98b8
spProductshttps://authoring-docs-microsoft.poolparty.biz/devrel/43b2e5aa-8a6d-4de2-a252-692232e5edc8

Links:

Skip to main content https://learn.microsoft.com/en-us/windows/win32/api/errhandlingapi/nf-errhandlingapi-setlasterror#main
Skip to Ask Learn chat experience https://learn.microsoft.com/en-us/windows/win32/api/errhandlingapi/nf-errhandlingapi-setlasterror
Download Microsoft Edge https://go.microsoft.com/fwlink/p/?LinkID=2092881
More info about Internet Explorer and Microsoft Edge https://learn.microsoft.com/en-us/lifecycle/faq/internet-explorer-microsoft-edge
Read in English https://learn.microsoft.com/en-us/windows/win32/api/errhandlingapi/nf-errhandlingapi-setlasterror
Edit https://github.com/MicrosoftDocs/sdk-api/blob/docs/sdk-api-src/content/errhandlingapi/nf-errhandlingapi-setlasterror.md
signing inhttps://learn.microsoft.com/en-us/windows/win32/api/errhandlingapi/nf-errhandlingapi-setlasterror
SetLastErrorExhttps://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setlasterrorex
GetLastErrorhttps://learn.microsoft.com/en-us/windows/win32/api/errhandlingapi/nf-errhandlingapi-getlasterror
Error Handling Functionshttps://learn.microsoft.com/en-us/windows/win32/Debug/error-handling-functions
GetLastErrorhttps://learn.microsoft.com/en-us/windows/win32/api/errhandlingapi/nf-errhandlingapi-getlasterror
Last-Error Codehttps://learn.microsoft.com/en-us/windows/win32/Debug/last-error-code
SetLastErrorExhttps://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setlasterrorex
Vertdll APIs available in VBS enclaveshttps://learn.microsoft.com/en-us/windows/win32/trusted-execution/enclaves-available-in-vertdll
en-ushttps://learn.microsoft.com/en-us/windows/win32/api/errhandlingapi/nf-errhandlingapi-setlasterror
Your Privacy Choiceshttps://aka.ms/yourcaliforniaprivacychoices
AI Disclaimerhttps://learn.microsoft.com/en-us/principles-for-ai-generated-content
Previous Versionshttps://learn.microsoft.com/en-us/previous-versions/
Bloghttps://techcommunity.microsoft.com/t5/microsoft-learn-blog/bg-p/MicrosoftLearnBlog
Contributehttps://learn.microsoft.com/en-us/contribute
Privacyhttps://go.microsoft.com/fwlink/?LinkId=521839
Consumer Health Privacyhttps://go.microsoft.com/fwlink/?linkid=2259814
Terms of Usehttps://learn.microsoft.com/en-us/legal/termsofuse
Trademarkshttps://www.microsoft.com/legal/intellectualproperty/Trademarks/

Viewport: width=device-width, initial-scale=1.0


URLs of crawlers that visited me.