Look here. I'm sure you can port the C# example to C++.