How to get error messages from Windows Imaging Component (WIC) using C++?

428 views Asked by At

I've been experimenting with Windows Imaging Component (WIC) in C++ and while everything works I'd like to be able to display descriptive error messages when WIC fails to load or transform an image.

MSDN documents the various error codes but no way of getting the error message. The solution is probably a combination of LoadLibrary(...) to get the hModule followed by FormatMessage(FORMAT_MESSAGE_FROM_HMODULE, ...). I haven't found the correct DLL to load yet.

Any help is much appreciated.

1

There are 1 answers

0
Chuck Walbourn On

Try FormatMessage with FORMAT_MESSAGE_FROM_SYSTEM. A number of errors were added for Windows 8.x, so it likely returns more useful results on that platform.

See this blog post for an updated version of the venerable DXERR.LIB which includes WIC errors.