Since winerror.h uses the preprocessor #define to associate a "message id" with the numeric value you would need to create your own lookup table. There is no Windows API function to convert the actual error code to the "message id" that is seen by the preprocessor.
How to convert a message number to a message ID

Ahmed Osama
120
Reputation points
How to convert a message (ex:13928) to an Message ID (ex: ERROR_IPSEC_DOSP_STATE_LOOKUP_FAILED) How to do that?
When retrieving an error code using GetLastError():
GetLastError()
It retrives an code, not a message ID or message
How do I convert an error code to a message ID and without loops?
Accepted answer
To get it from WINERROR.H, use this code to get the handle of the file:
You'll have to get that answer from Microsoft.
I want a way that is:
Future-compliant (responds to changes in the OS)
Returns the message ID (EX: ERROR_ACCESS_DENIED)
Past-compliant and Past-compatible (responds to past and future changes in the error code message ID and compatible with older OSes)
I would need it to be dynamic
Time now is 3/3/2023 1:27:20 PM EET
Well, it seems to me that you should propose your feature request to Microsoft.
Sign in to comment