Re:谁知道禁用USB端口的函数啊!?! 是不是要自己写方法哦!
http://www.codeproject.com/system/EnumDevices.asp
http://www.codeproject.com/system/change_drive_sn.asp
http://www.codeproject.com/system/installed_programs.asp
http://www.codeproject.com/system/enum_display_modes.asp
http://www.codeproject.com/system/serial_portsenum_fifo.asp
1Minimize any window to system tray using Windows Hook
http://www.codeproject.com/system/DevicePropertySheet.asp
http://www.codeproject.com/system/chaiyasit_t.asp
http://www.codeproject.com/system/DevMgr.asp 001
http://www.codeproject.com/system/eject_cdrom.asp
http://www.codeproject.com/system/serviceskeleton.asp 002
http://www.codeproject.com/useritems/HwDetect.asp 003
Re:谁知道禁用USB端口的函数啊!?! 是不是要自己写方法哦!
我做了个MP3的量产软件,当对MP3的文件download完成后会将MP3安全移除。
问题是:我用GUID{0xA5DCBF10L, 0x6530, 0x11D2, 0x90, 0x1F, 0x00, 0xC0, 0x4F, 0xB9, 0x51, 0xED}会将USB键盘和USB鼠标全都枚举出来,这样我就无法区分谁是MP3,谁是USB键盘和鼠标了。虽然枚举时我可以得到PID和VID,但是我们的PID和VID可能会被代理商更改,所以也就不能通过PID和VID来区分了,不知PC上的安全删除U盘是怎样做到的,PC应该可以将盘符和对应的设备对应起来,且能用唯一的标识来区分每台设备,情况紧急,求求各位高手拉我一把吧,非常感谢!
我的代码如下:
void CLogicDriveList::RemoveDevice(size_t index)
{
char szDevDesc[256] = {0};
HDEVINFO hDevInfo;
string Prod;
string Rev;
//遍历所有的设备
hDevInfo = SetupDiGetClassDevs((LPGUID)&GUID_CLASS_USB_DEVICE, NULL, NULL, DIGCF_PRESENT|DIGCF_DEVICEINTERFACE) if ( INVALID_HANDLE_VALUE == hDevInfo)return;
SP_DEVINFO_DATA devInfoData;
devInfoData.cbSize = sizeof(devInfoData);
int Index = 0;
while(SetupDiEnumDeviceInfo(hDevInfo, Index++, &devInfoData))
{
//获取设备ID
std::string devId;
memset(szDevDesc, 0, sizeof(szDevDesc));
devInfoData.cbSize = sizeof(devInfoData);
CM_Get_Device_ID(devInfoData.DevInst, szDevDesc, sizeof(szDevDesc),0);
devId = szDevDesc;
cout<<devId<<endl;
//比较设备ID
if(这里该怎样填呢?)
{
if(EjectDevice(devInfoData))
{
cout<<"Remove device "<<m_LogicDrives [index].Symbol<<": ok"<<endl;
break;
}
else
cout<<"Remove device "<<m_LogicDrives[index].Symbol<<": fail"<<endl;
}
}
}
bool CLogicDriveList::EjectDevice(const SP_DEVINFO_DATA &devInfoData)
{
PNP_VETO_TYPE pnpvietotype;
char vetoname[MAX_PATH] = {0};
CONFIGRET cr = CM_Request_Device_Eject(devInfoData.DevInst,
&pnpvietotype,
vetoname,
MAX_PATH,
0);
return CR_SUCCESS==cr;
}