DavidCrow wrote:
It appears that I have steps 1-5 in place. Do you agree?
Nope, I don't agree. Not unless you've altered the code you presented earlier where you tried to create an instance of CMyEventHandler
by calling CreateInstance()
into what I suggested, e.g. using new
.
DavidCrow wrote:
Does the duck sample talk about how to avoid the GUID error that I'm battling?
Nope. The question is irrelevant as a CLSID for CMyEventHandler
won't be needed when you create a CMyEventHandler
on the heap or the stack. Note that what the compiler complains about is a missing "Class ID", CLSID, since it refers to the 'object' CMyEventHandler
. The CLSID is the identity of the server one is trying to create with a call to CreateInstance()
. This is not the same as the identity of the interface you're trying to use called "Interface ID" or IID, which also has a Globally Unique IDentifier assigned to it. Your CMyEventHandler
declaration should look something like this:
class ATL_NO_VTABLE CMyEventHandler :
public CComObjectRootEx<CComSingleThreadModel>,
public IWMPEvents
{
public:
BEGIN_COM_MAP( CMyEventHandler )
COM_INTERFACE_ENTRY(IWMPEvents)
END_COM_MAP()
public:
/\* Here goes declarations of the functions in the IWMPEvents interface \*/
};
The code where you create the Media Player server should look something like this, as partially described in the article:
CComPtr<IWMPPlayer> spWMPPlayer;
CComPtr<IConnectionPoint> spConnectionPoint;
DWORD dwAdviseCookie;
HRESULT hr;
/* I don't know the CLSID or ProgID of the Media Player server as I'm currently sitting on an
** Ubuntu machine at home, but let's just assume you've successfully created the Media Player
** server and you have a valid interface pointer for it: spWMPPlayer.
** Anyway you seem to have taken care of that already. ;-)
*/
/* Create the CMyEventHandler object */
CMyEventHandler* pMyEventHandler = new CComObject<CMyEventHandler>;
/* Get the connection point */
CComQIPtr<IConnectionPointContainer, &__uuidof(IConnectionPointContainer)> spConnectionContainer( spWMPPlayer );
if( spConnectionContainer )
{
hr = spConnectionContainer->FindConnectionPoint( __uuidof(IWMPEvents), &spConnectionPoint )
if( pMyEventHandler && SU