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
2 additional answers
Sort by: Most helpful
-
Castorix31 87,886 Reputation points
2023-03-02T16:56:22.7366667+00:00 With FormatMessage
But it depends on the resource DLL
13928 gives "La protection DoS IPsec n’a pas pu rechercher l’état.\r\n" on my french OS
-
simonberrurier-7045 41 Reputation points
2023-03-03T10:04:40.3966667+00:00 It retrives an code, not a message ID or message
FormatMessage is the way to get the message from a system code