Obtaining message descriptions

To obtain the description at runtime for a Win32 error code you use the Win32 FormatMessage function. This will get the description for a system message or for a custom message (described in the next section). If you want to use a custom message you have to load the executable (or DLL) that has the message resource bound to it and pass the HMODULE handle to the FormatMessage function. If you want to get the description of a system message you do not need to load a module because Windows will do this for you. For example, if you call the Win32 CreateFile function to open a file and the file cannot be found, the function will return a value of INVALID_HANDLE_VALUE, indicating that there is an error. To get details ...

Get Beginning C++ Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.