내 응용 프로그램에서 웹캠을 사용하지 않으려합니다. 장치 관리자의 장치 상태가 비활성화에서 사용 가능으로 변경되지만 장치는 여전히 활성 상태이고 장치 등록 정보 창을 닫으려고 할 때. 시스템을 다시 시작하지 않고 코드를 통해 수행 할 수 있습니다.windows 장치 사용 안 함
int main(int argc, void * argv[])
{
HDEVINFO hDevInfo;
SP_DEVINFO_DATA DeviceInfoData;
DWORD i;
SP_PROPCHANGE_PARAMS params; // params to set in order to enable/disable the device
// Create a HDEVINFO with all present devices.
hDevInfo = SetupDiGetClassDevs(NULL,0, 0,DIGCF_PRESENT | DIGCF_ALLCLASSES);
if (hDevInfo == INVALID_HANDLE_VALUE)
{
// Insert error handling here.
return 1;
}
// Enumerate through all devices in Set.
DeviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
for (i=0;SetupDiEnumDeviceInfo(hDevInfo,i,&DeviceInfoData);i++)
{
wchar_t szPhysical[MAX_PATH] = {0};
const char *sstt ="\\Device\\00000079";
while (!SetupDiGetDeviceRegistryProperty(hDevInfo,&DeviceInfoData,SPDRP_PHYSICAL_DEVICE_OBJECT_NAME,0L,(PBYTE)szPhysical,2048,0)){}
if(szPhysical[0]==sstt[0])
if(szPhysical[1]==sstt[1])
if(szPhysical[2]==sstt[2])
if(szPhysical[3]==sstt[3])
if(szPhysical[4]==sstt[4])
if(szPhysical[5]==sstt[5])
if(szPhysical[6]==sstt[6])
if(szPhysical[7]==sstt[7])
if(szPhysical[8]==sstt[8])
if(szPhysical[9]==sstt[9])
if(szPhysical[10]==sstt[10])
if(szPhysical[11]==sstt[11])
if(szPhysical[12]==sstt[12])
if(szPhysical[13]==sstt[13])
if(szPhysical[14]==sstt[14])
if(szPhysical[15]==sstt[15]){
printf("disabling...\n");
// init the structure
params.ClassInstallHeader.cbSize = sizeof(SP_CLASSINSTALL_HEADER);
params.ClassInstallHeader.InstallFunction = DIF_PROPERTYCHANGE;
params.HwProfile = 0;
params.Scope = DICS_FLAG_CONFIGSPECIFIC;
params.StateChange = DICS_DISABLE;
// prepare operation
if (!SetupDiSetClassInstallParams(hDevInfo, &DeviceInfoData,¶ms.ClassInstallHeader, sizeof(params)))
{
printf("Error while preparing params !\n");
break;
}
// launch op
if (!SetupDiCallClassInstaller(DIF_PROPERTYCHANGE, hDevInfo, &DeviceInfoData))
{
printf("Error while calling OP ! Return code is %x\n", GetLastError());
continue;
}
printf("done.\n\n");
}
}
if (GetLastError()!=NO_ERROR &&GetLastError()!=ERROR_NO_MORE_ITEMS)
{
// Insert error handling here.
return 1;
}
// Cleanup
SetupDiDestroyDeviceInfoList(hDevInfo);
return 0;
}
어떤 도움이 확실히 완전한 답변 아니므로, 그렇지 않으면 내가 가진 것,
감사
답장을 보내 주셔서 감사합니다.이 구현 또는 링크에 대한 예제를 제공 할 수 있습니까? – bhupinder
을 직접 카메라에 감지 할 수 없습니다. – bhupinder
이 WMI 클래스에 대한 참조 문서는 다음과 같습니다. http://msdn.microsoft.com/en-us/library/aa394472(v=vs.85).aspx,하지만 이해해야 할 내용이 있습니다. WMI를 일반적으로 사용하는 방법 (짐승 같은 것). 어쨌든, 당신이 문제를 풀어 낸 것처럼 들리지만, 당신의 질문을 매달 리고 싶지는 않습니다. – Aaron