This post originated from an RSS feed registered with .NET Buzz
by Eric Gunnerson.
Original Post: What's wrong with this code (COM Interop)?
Feed Title: Eric Gunnerson's C# Compendium
Feed URL: /msdnerror.htm?aspxerrorpath=/ericgu/Rss.aspx
Feed Description: Eric comments on C#, programming and dotnet in general, and the aerodynamic characteristics of the red-nosed flying squirrel of the Lesser Antilles
A special "COM Interop" edition of "What's Wrong with this code?"
This code is using some Windows Media interfaces to get the properties from a profile.
IWMMediaProps::GetMediaType() gets a _WMMediaType structure. Because there is optional format data that comes back, you have to call the method once to get the size, then again to get the actual data. You can assume that that extra data is a WAVEFORMATEX structure. In the C# world, the pbFormat field in _WMMediaType is an IntPtr.
Here's the code. There's something bad lurking there. I think I've given you enough information to figure it out.