Skip to main content
gamedev.net
🔒 Locked

IUnknown interface

Started by henryx Jan 7, 2002 at 8:24 AM 3 replies 1.1k views
Original Post
henryx
henryx
I have a question regarding how to access the IUnknown interface. For example, the method IDirectMusicPerformance8::StopEx has the prototype: HRESULT StopEx( IUnknown *pObjectToStop, __int64 i64StopTime, DWORD dwFlags ); The first parameter is a pointer to the IUnknown interface of the object that needs to be stoped (in my case a music midi file). I have pointers to the segment that is playing and it''s segment state: IDirectMusicSegment8* g_pSegment; IDirectMusicSegmentState* g_pSegmentState; but how do I get access to the IUnknown interface for the object that I need to stop. Thanks henry
HenryLecturer in Computer Games TechnologyUniversity of Abertay DundeeScotlandUK
Choff
Choff
Look-up the functions CoCreateIntance, CocreatetInstanceEx and QueryInterface. I'm not at home so I don't have an example off the top of my head.

You may have to change the code to get the Music interfaces second, instead of getting them from the directx objects indirectly.

general steps:

1)Use CocreatetInstanceEx and a pointer to Iunknown to create the music object, save this iunknown for later.
2)Use Iunknown and queryinterface to make the music interfaces
3)you can now use iunknown to stop the music.

BUT also see if the music interfaces have QueryInterface built in already. Then you just call QueryInterface on the Music interfaces to get Iunknown...

hope that helps and take the advice with a grain of salt.. going on memory...



Edited by - choff on January 7, 2002 10:02:44 AM
==========================big kid with adult powers==========================
henryx
henryx
Thanks loads choff, Ive got it now.

As you suggest I can get the IUnknown interface pointer using:

Hr = g_pSegment->QueryInterface(IID_IDirectMusicSegment8, (LPVOID*)&pObjectToStop);

and pObjectToStop works with the SopEx method.

Thanks again,

henry
HenryLecturer in Computer Games TechnologyUniversity of Abertay DundeeScotlandUK
Kaijin
Kaijin
Jim is correct. IDirectMusicSegment8 and IDirectMusicSegmentState both inherit from IUnknown (as do all DirectX interfaces) and are therefor subtypes of IUknown. This means they can be passed to any parameter that takes an IUknown object.

- Kaijin

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.