DirectShow is a COM based technology. COM uses for error reporting the (in)famous HRESULTs.
These HRESULTs are numbers like 0x80040227, but what do they mean? Visual Studio has a nifty MFC utility called "Error Lookup". But what happens if you lookup 0x80040227? "Message not found" pops up.
It seems that the DirectShow HRESULTs are out of reach for "Error Lookup". "Error Lookup" has a button named "Modules", maybe we can add the DirectShow HRESULTs there.
After adding "QUARTZ.DLL" in "Error Lookup" module list, 0x80040227 becomes "The operation could not be performed because the filter is in the wrong state." Sometimes the trick of adding quartz.dll doesn't work, then what?
DirectX has some nice error lookup functions named DXGetErrorString and DXGetErrorDescription, which give information about DirectX components and Win32 functions.
I have made a small tool called dxerr (source code here) which makes use of the two functions.
You might be tempted to use these two functions in your programs, but note that these functions might increase your binary with a couple of hundred kilobytes, and you need to have the DirectX SDK installed.
With the use of dxerr 0x80040227 has also a name: VFW_E_WRONG_STATE, which you might have found out by doing a Google search.
Here is a screenshot displaying "Error Lookup" and "dxerr".
After creating the "dxerr" tool I've found out that there is a tool named "DXErr.exe" in the DirectX SDK under "Utilities\bin\x86". I had no idea about that, but now that I know about it, it doesn't make a big difference :)
dxerr can be of use to those who do not have the DirectX SDK installed, to those who program with other programming languages than C++, or to those who program using C++ but with a compiler from a different vendor.
2 comments:
Error Lookup gets you the string from error code using FormatMessage API, with quartz.dll module handle. Quartz.dll has all strings in the MESSAGETABLE resource.
So it is another option: instead of static link to embed error descriptions, you can use FormatMessage to get them right from quartz.dll.
This free online tool here: https://www.magnumdb.com is a database that contains more than 350000 constants that you can query by name or value. It will easily tell you that 0x80040227 is indeed VFW_E_WRONG_STATE (it also matches other errors because 0x8004 is generic facility).
Post a Comment