To use IComponentAuthenticate with an application
- Include Sac.h and Scclient.h.
- Link to Mssachlp.lib.
- Add the Keys.c file that you received when you signed the license agreement for your project.
- 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.
- 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
© 1999 Microsoft Corporation. All rights reserved.