Partager via


Declaration of Service Provider Interfaces

banner art

A service provider is a plug-in to Windows Media Device Manager. It is a closely integrated COM object that implements the interfaces detailed in WMSP.idl. Because it facilitates interaction between Windows Media Device Manager and a portable device, implementing the service provider includes writing code that makes calls to the proprietary firmware on a portable device.

Authentication similar to that used to access Windows Media Device Manager is also necessary before calling the methods of service provider interfaces. Whereas a fully functional authentication interface is provided by Windows Media Device Manager, the IComponentAuthenticate interface must be implemented by the developer on the service provider. The object that implements the IMDServiceProvider interface must also implement the IComponentAuthenticate interface.

Creation of the basic structure of the service provider can be done using an ATL COM project in Microsoft Visual C++. To begin an ATL implementation of a service provider follow these steps:

  1. Create a DLL project.

  2. Add a simple ATL COM object, free threaded or apartment threaded. Use a custom interface, because IDispatch is not supported by Windows Media Device Manager.

  3. Include the authentication headers:

    #include "sac.h"
    #include "scserver.h"
    #include "key.c"
    
  4. Add the following files to the project:

    wmdm.idl

    wmsp.idl

    icomponentauthenticate.idl

  5. In the .idl file that describes the basic COM object, add the following import statements:

    import "WMDM.idl";
    import "WMSP.idl";
    import "icomponentauthenticate.idl";
    
  6. Declare a member variable for the CSecureChannelServer class. This variable must accessible to all other objects in the component.

    CSecureChannelServer m_CSecureChanServ;
    
  7. Add the service provider interface statements to the library section of the project idl:

    interface IMDServiceProvider;
    interface IComponentAuthenticate;
    interface IMDSPDevice;
    interface IMDSPDevice;
    interface IMDSPEnumStorage;
    interface IMDSPObject;
    interface IMDSPStorage;
    
  8. Build the project to create the type library and necessary headers for applications that will use this service provider.

  9. Use the Implement Interface dialog box to structure the basic implementation of IMDServiceProvider.

  10. Similarly, use Implement Interface to add the IComponentAuthenticate interface. The code required for authentication interfaces is shown in the topic To Implement IComponentAuthenticate in a Service Provider.

  11. Create the registration script to register the service provider as a Windows Media Device Manager plug-in. See Registering Service Providers.

  12. Rebuild the project to complete the basic structure of the service provider and register the component.

After implementing three service provider interfaces, the header file for the main COM object should begin something like this:

class ATL_NO_VTABLE CExampleObject : 
    public CComObjectRootEx<CComMultiThreadModel>,
    public CComCoClass<CExampleObject, &CLSIDExampleObject>,
    public IExampleObject,
    public IMDServiceProvider,
    public IComponentAuthenticate,
    public IMDSPEnumDevice
{
public:
CExampleObject()
{
}

DECLARE_REGISTRY_RESOURCEID(IDR_ExampleObject)
DECLARE_NOT_AGGREGATABLE(CExampleObject)
DECLARE_GET_CONTROLLING_UNKNOWN()

BEGIN_COM_MAP(CExampleObject)
    COM_INTERFACE_ENTRY(IExampleObject)
    COM_INTERFACE_ENTRY(IMDServiceProvider)
    COM_INTERFACE_ENTRY(IComponentAuthenticate)
    COM_INTERFACE_ENTRY(IMDSPEnumDevice)
END_COM_MAP()

See Also