Created
January 5, 2024 02:04
-
-
Save cristeigabriel/7df945b01987cbee8b1e0fee658edc1c to your computer and use it in GitHub Desktop.
error print code for mastodon
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <windows.h> | |
#include <cstdio> | |
static LPWSTR getErrorStr(DWORD code) { | |
LPWSTR buffer = nullptr; | |
FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER, | |
nullptr, code, LANG_USER_DEFAULT, (LPWSTR)&buffer, 0, | |
nullptr); | |
return buffer; | |
} | |
int main() { | |
DWORD code = 0x80000003; | |
auto str = getErrorStr(code); | |
if (str) { | |
wprintf(L"%s\n", str); | |
LocalFree(str); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment