Sign in to follow this  

DirectMusic question?

This topic is 4201 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm pretty sure this post should go here. I am learning how to create a sound class for my project using DirectMusic. I have a question on the call to CoCreateInstance. I have two variables: IDirectMusicLoader8 *m_loader; CoCreateInstance( CLSID_DirectMusicLoader, NULL, CLSCTX_INPROC, IID_IDirectMusicLoader8, (void**)&m_loader ); This is probably a dumb question buy why is m_loader cast with (void**). I don't understand the reason or what this is accomplishing. Thanks in advance for the help.

Share this post


Link to post
Share on other sites
Hmmm maybe I'm not right, but I think that's because DirectX stuff innherits from IUnknown interface. So you have to pass void pointer to it because IUnknown interface does not know which type you are using so interface use void*. That's why is there another pointer to reference (void**)& to get proper adress of DirectX interface (in this example DirectMusic).

But maybe I'm wrong [smile]

Share this post


Link to post
Share on other sites
CoCreateInstance can actually create COM objects of any type depending on the other parameters, so it expects a void** to put the result into instead of a IDirectMusicLoader8** or whatever.

tj963

Share this post


Link to post
Share on other sites

This topic is 4201 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this