OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Can you translate a GetLastError() error code into the name of the #define?

  • Thread starter Thread starter Dr. Gut
  • Start date Start date
D

Dr. Gut

Guest
GetLastError() returns a DWORD. Is there a Windows API function that translates this DWORD into a string, the name of the #define? E.g. for 123 it would return "ERROR_INVALID_NAME". Here is a list of system error codes.

FormatMessage doesn't seem to do the job, but the Microsoft Error Lookup Tool somehow prints the name of the #define.
<p><a href="https://learn.microsoft.com/windows/win32/api/errhandlingapi/nf-errhandlingapi-getlasterror" rel="nofollow noreferrer"><code>GetLastError()</code></a> returns a <code>DWORD</code>. Is there a Windows API function that translates this <code>DWORD</code> into a string, the name of the <code>#define</code>? E.g. for <code>123</code> it would return <code>"ERROR_INVALID_NAME"</code>. Here is a <a href="https://learn.microsoft.com/windows/win32/debug/system-error-codes--0-499-" rel="nofollow noreferrer">list of system error codes</a>.</p>
<p><a href="https://learn.microsoft.com/windows/win32/api/winbase/nf-winbase-formatmessage" rel="nofollow noreferrer"><code>FormatMessage</code></a> doesn't seem to do the job, but the <a href="https://learn.microsoft.com/windows/win32/debug/system-error-code-lookup-tool" rel="nofollow noreferrer">Microsoft Error Lookup Tool</a> somehow prints the name of the <code>#define</code>.</p>
I have found how to fix this.
 
Top