I used SetupDiSetClassInstallParams and SetupDiCallClassInstaller to disable specific USB device.
SP_PROPCHANGE_PARAMS params;
params.ClassInstallHeader.cbSize = sizeof(SP_CLASSINSTALL_HEADER);
params.ClassInstallHeader.InstallFunction = DIF_PROPERTYCHANGE;
params.StateChange = DICS_DISABLE;
// SP_DEVINFO_DATA - Info.DevInfoData
if (!SetupDiSetClassInstallParams(hDevInfo, &(Info.DevInfoData),¶ms.ClassInstallHeader, sizeof(params))) {
Error = GetLastError();
return Error;
}
if (!SetupDiCallClassInstaller(DIF_PROPERTYCHANGE, hDevInfo, &(Info.DevInfoData))) {
Error = GetLastError(); // error here
}
This approach works to all devices, except keyboard. If i try to disable her this way ERROR_NOT_DISABLEABLE returned. But after reboot keyboard will be disabled.
Before disabling, flags DN_DISABLEABLE and DN_REMOVABLE seted for this device, checked by function CM_Get_DevNode_Status. What i am doing wrong?
This device don't support disabling