Windows Media Format SDK banner art
PreviousNext

To use IComponentAuthenticate with an application

  1. Include Sac.h and Scclient.h.

  2. Link to Mssachlp.lib.

  3. Add the Keys.c file that you received when you signed the license agreement for your project.

  4. Declare a CSecureChannelClient object. This object must be available to any routines that call Windows Media Device Manager. For example, if your application has only a single code path, the CSecureChannelClient object can be a local variable, but if you have a user interface and several code paths, it must be a global object.

  5. Ask for IComponentAuthenticate from your call to CoCreateInstance on Windows Media Device Manager. Then insert code similar to the following:
    IComponentAuthenticate *pAuth = NULL;
    CSecureChannelClient SAC;

    hr = CoCreateInstance(CLSID_MediaDevMgr, NULL, CLSCTX_INPROC_SERVER,
                            IID_IComponentAuthenticate, (void**)&pAuth);
        if (SUCCEEDED(hr))
        {
            pCert = LockResource(hCert);
            hr = SAC.SetCertificate((BYTE*)abCert, sizeof(abCert),
                                     (BYTE*)abPVK, sizeof(abPVK));
            SAC.SetInterface(pAuth);

            hr = SAC.Authenticate(SAC_PROTOCOL_V1);
            if (FAILED(hr))
                goto exit;

            hr = pAuth->QueryInterface(IID_IWMDeviceManager,
                                          (void**)&pDevMgr);
            if (FAILED(hr))
                goto exit;
        }

See Also

PreviousNext


© 1999 Microsoft Corporation. All rights reserved.