可能中斷連線裝置的程式代碼範例
重要
WSD Challenger 功能已被取代,且所有 WSD Challenger 相關文件都會封存到舊版檔。
下列程式代碼範例示範對 RegisterDeviceToChallenge 函式的呼叫 (,此函式列於實 作 Helper 方法的範例程式代碼 範例中,) 以挑戰可能中斷連線的裝置。
HRESULT hr = S_OK;
if (SUCCEEDED(hr))
{
//
// Activate ScanProxy to retrieve the IScanService interface for it
//
hr = m_pFunctionInstance->QueryService(__uuidof(WSDScanProxy),
__uuidof(IScanService),
(void**) &m_pScanProxy);
if (FAILED(hr))
{
WIAS_ERROR((g_hInst, "IFunctionInstance::QueryService(WSDScanProxy, IScanService) failed, cannot activate ScanProxy, hr = 0x%08X", hr));
if (WSD_COMMUNICATION_ERROR(hr))
{
RegisterDeviceToChallenge();
}
}
}
if (SUCCEEDED(hr))
{
//
// Retrieve the IScanServiceEvents interface from the ScanProxy
//
hr = m_pScanProxy->QueryInterface(__uuidof(IScanServiceEvents), (void**)&m_pScanEvents);
if (FAILED(hr))
{
WIAS_ERROR((g_hInst, "IScanService::QueryInterface(IScanServiceEvents) failed, hr = 0x%08X", hr));
if (WSD_COMMUNICATION_ERROR(hr))
{
RegisterDeviceToChallenge();
}
}
}