系统无法识别MTP设备??
HRESULT hr;
CComPtr<IComponentAuthenticate> pAuth = NULL;
IWMDeviceManager3 * pIWMDevMgr3 = NULL;
IWMDMEnumDevice *pEnumDevice = NULL;
// Initialize member variables
m_pSAC = NULL;
m_pWMDevMgr = NULL;
m_pWmdmDevice = NULL;
//
// Acquire the authentication interface of WMDM
//
hr = CoCreateInstance(
CLSID_MediaDevMgr,
NULL,
CLSCTX_INPROC_SERVER,
IID_IComponentAuthenticate,
(void**)&pAuth
);
ExitOnFail( hr );
// Create the client authentication object
m_pSAC = new CSecureChannelClient;
ExitOnNull( m_pSAC );
//
// Select the cert and the associated private key into the SAC
//
hr = m_pSAC->SetCertificate(
SAC_CERT_V1,
(BYTE *)abCert, sizeof(abCert),
(BYTE *)abPVK, sizeof(abPVK)
);
ExitOnFail( hr );
//
// Select the authentication interface into the SAC
//
m_pSAC->SetInterface( pAuth );
//
// Authenticate with the V1 protocol
//
hr = m_pSAC->Authenticate( SAC_PROTOCOL_V1 );
ExitOnFail( hr );
//
// Authenticate succeeded, so we can use the WMDM functionality.
// Acquire an interface to the top-level WMDM interface.
//
hr = pAuth->QueryInterface( IID_IWMDeviceManager, (void**)&m_pWMDevMgr );
ExitOnFail( hr );
hr = m_pWMDevMgr->QueryInterface (IID_IWMDeviceManager3, (void**) &pIWMDevMgr3);
if (SUCCEEDED (hr))
{
hr = pIWMDevMgr3->EnumDevices2(&pEnumDevice);
pIWMDevMgr3->Release();
}
ExitOnFail( hr );
while( TRUE )
{
IWMDMDevice *pWmdmDevice;
ULONG ulFetched;
WCHAR szManufacturer[128];
hr = pEnumDevice->Next( 1, &pWmdmDevice, &ulFetched );
///hr得到失败的值,没有找到MTP设备????
。。。。。。。。。。。。
。。。。。。。。。。。。。。
#define ExitOnFail( hr ) if ( FAILED(hr) ) goto lExit;