Reputation: 4914
We have a custom NDIS protocol and miniport drivers for Windows Mobile 6.5. We'd like to allow the user to uninstall these drivers cleanly, however uninstall currently gives the error: " was not completely removed. Do you want to remove it from the list of installed programs?" This is probably happening because the drivers are still in use (as reported by Remote Process Viewer). Unfortunately, I cannot figure out how to unload the drivers (assuming that is the problem). The drivers are for hardware that is built-in to the device, so it is not possible to simply remove the device and have the drivers unloaded
[edit] I should have probably mentioned the whole problem when I wrote this. I really care about updating the driver. I don't necessarily have to uninstall the old driver to do that.
Upvotes: 1
Views: 629
Reputation: 4914
One possibility is to launch a program at Windows Mobile startup that will delete the old driver and copy the new one in to place.
This can be accomplished using HKEY_LOCAL_MACHINE\Init
as documented here:
Here is a sample program:
#include <windows.h>
int _tmain(int argc, _TCHAR* argv[])
{
// delete the old driver
BOOL result = DeleteFile(L"\\Windows\\MyDriver.dll");
if (result)
{
// put the new driver in place
result = MoveFile(L"\\My Documents\\MyDriver_NEW.dll",
L"\\Windows\\MyDriver.dll");
}
// Delete us from the registry
HKEY regKey = 0;
LONG regResult = RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"init", 0, KEY_SET_VALUE, ®Key);
result = regResult == ERROR_SUCCESS;
if (result)
{
regResult = RegDeleteValue(regKey, L"Depend19");
result = regResult == ERROR_SUCCESS;
if (result)
{
regResult = RegDeleteValue(regKey, L"Launch18");
result = regResult == ERROR_SUCCESS;
}
RegCloseKey(regKey);
}
// we need to tell WinCE we started properly
SignalStarted(_ttoi(argv[1]));
return 0;
}
The values of 'Launch18' and 'Depend19' will probably be different on your platform. Just make sure this program is run before device.exe.
Note: On many platforms this program will have to be signed and your certs need to be installed on the device. If it isn't then it won't run.
Upvotes: 0
Reputation: 67178
You can probably call DeactivateDevice, though you need to have the driver's handle (from whomever called ActivateDevice). For CE 5.0 and earlier, at least for stream drivers, the device manager actually put this in the registry under HKLM/Drivers/Active
.
I've not looked for NDIS as I've never wanted to unload one. For that you might need to call DeviceIoControl to the NDIS driver with IOCTL_NDIS_UNBIND_ADAPTER and/or IOCTL_NDIS_DEREGISTER_ADAPTER
Upvotes: 1