Working with DirectShow in VS2005
May 26, 2010
We regularly receive questions how to build the C++ source code generated by
GraphEditPlus. It generates some code, but in
order to turn it into an executable one needs to create and properly set up
a Visual Studio project.
Here's a short tutorial on how to start working with DirectShow in C++ using
Microsoft Visual Studio 2005. It's also actual for VS2008 and probably VS2010.
To work with DirectShow first of all you need DirectShow headers and libs.
Currently they are included in Windows SDK which can be downloaded from
Microsoft website. If you don't have it installed yet, go install it now and
then come back.
By default it's being installed into
C:\Program Files\Microsoft SDKs\Windows\v7.0. If you install it
to some other place, make appropriate changes to the paths below.
Now, run Visual Studio and create a C++ project.
In this tutorial I'll pick a console application, for simplicity.
Give it a name and choose a path:
Open the main CPP file:
Now run GraphEditPlus, create a graph and generate C++ code for it:
Copy the source code to the main CPP file.
Now open menu Project -> Properties, go to C++ / General window and
add the path to DirectShow header files.
Then in Linker / General window add path to the lib files:
In Linker / Input window add strmiids.lib and quartz.lib:
Close the properties window and build the project.
If all paths are set correctly your app is now ready!
P.S. It turns out that there is a little problem in the code generated by
GraphEditPlus: the strings there are currently ANSI strings like "this", not
Unicode strings like L"this" or generic ones like _T("this"). When your project
is set up for Unicode, this causes some troubles. There are two possible fixes:
1. (slow but proper one) embrace all string constants into _T(), or
2. (quick fix) change the hrcheck helper function to work with
char's instead of TCHAR's.
Later versions of GraphEditPlus will generate proper code, using the
first approach.
tags: directshow
|