我已经创建了一个驱动程序并安装在com端口中。卸载驱动程序时,将卸载驱动程序。但是当我重新安装相同的驱动程序时,com端口号增加了(COM1,COM2,...... COMN)。我用WinAPI删除了驱动程序,下面是代码.....
HDEVINFO devs = NULL;
devs = SetupDiGetClassDevs(NULL,NULL,0, DIGCF_ALLCLASSES );
DWORD devCount = 0;
SP_DEVINFO_DATA devInfo;
int enumeratingDevices = 1;
/*This line is essential*/
DWORD dwSize, dwPropertyRegDataType;
TCHAR szDesc[MAX_STRING];
ZeroMemory(szDesc, sizeof(TCHAR) * MAX_STRING);
devInfo.cbSize = sizeof(SP_DEVINFO_DATA);
// Loop through the devices
for ( int i=0; SetupDiEnumDeviceInfo( devs , i , &devInfo) ; i++ )
{
//Here put some code to compare the our driver and uninstall the driver
SetupDiRemoveDevice(devs,&devInfo);
}
//Clean up
SetupDiDestroyDeviceInfoList(devs);
我想在重新安装驱动程序时使用相同的com端口号,以前是否已卸载?
谢谢!