How to convert an error code to an message ID? RRS feed

  • Question

  • How to convert the message ID returned by GetLastError() When calling GetLastError(), it returns an error code, but how to convert that code to a message ID? I have an error code, which Windows has for the message, but not the message ID, so it's only at non-compiled headers (ex: WinError.h) which has the code at the comments or at the declaration at the #define preprocessor constant variable name, which cannot be retrieved by compiled code because compiled code cannot interpret non-compiled ones, and this may make dependencies between the WinError.h file and the application (which may or may not be pre-compiled) and loops may decrease performance (windows error codes are 1000+) which is going to cause sluggish applications This is the code


    How to solve this and without loops?

    Some applications like Visual Studio are able to retrieve the message ID instantly

    I have tried a) searching winerror.h b) making own table (but no know-how to return the info from it) I have expected a) Success I have got a) nothing, only null string and it made the string terminate unexpectedly.

    Tuesday, March 7, 2023 1:59 PM