最近在调试蓝牙驱动的,想做成可以动态加载,也就是想加载的时候加载,卸载的时候卸载,我在应用程序这段用下面的代码
BOOL bRes = FALSE;
DEVMGR_DEVICE_INFORMATION di={0};
di.dwSize = sizeof(di);
//HANDLE hFindDevice = FindFirstDevice(DeviceSearchByLegacyName,TEXT("RES1:"),&di);
HANDLE hFindDevice = FindFirstDevice(DeviceSearchByDeviceName,_T("BTD0"),&di);
//HANDLE hFindDevice = FindFirstDevice(DeviceSearchByDeviceName,_T("PWR1"),&di);
if(hFindDevice == INVALID_HANDLE_VALUE)
{
MessageBox(_T("find BTD0 device fail!"));
}
else
{
MessageBox(_T("find BTD0 success success!"));
}
CloseHandle(hFindDevice);
bRes = DeactivateDevice(di.hDevice);
if(bRes)
{
MessageBox(_T("DeactivateDevice success!"));
}
else
{
MessageBox(_T("DeactivateDevice fail!"));
}
卸载的时候,停在DeactivateDevice函数中,系统就几乎没有响应了,应该大家有做过类型的应用,麻烦大家指教,谢谢了。
------解决方案--------------------
ActivateDeviceEx和DeactivateDevice
------解决方案--------------------
看LZ的情况,应该是蓝牙驱动的问题。添加调试信息,看看在卸载的时候哪里挂掉了