Search code examples
c++activexatlshockwave

C++ ATL Member Variable access help


I am not familiar with this, and can use a kick start.

I am using ATL (unmanaged C++) user control and would like to use the ShockWave ActiveX object. I need to know how to declare it so that I can set a property or call a method.

For instance, if I could assign a variable to it, then I would like to call 'variable->LoadMovie()'

I know this is super ridiculous... almost embarrassed to ask it here. ;) (almost)


Solution

  • If you #import the dll (which I recommend when working with COM because it makes your life SO much easier), you can use a smart pointer paired with the CLSID of the object. Remember that smart pointer classes have the post-fix 'Ptr' after the interface name.

    For instance:

    ISomeInterfacePtr pSomeInterface( CLSID_SomeComponent );
    HRESULT hr = pSomeInterface->SomeMethod();
    

    Hope that helps.

    EDIT: If you want to check the HRESULT of the allocation, you can do the following:

    ISomeInterfacePtr pSomeInterface = 0;
    HRESULT hr = pSomeInterface.CreateInstance( CLSID_SomeComponent );