You can probably modify
this example to check if your device is installed. The example gives the friendly names though not device ids. Generally you'll want to look through the setup api for this sort of thing.
Since drivers are handled by the service control manager, you might be able to use
StartService to start / load a driver and
ControlService with SERVICE_CONTROL_STOP to stop / unload it. EDIT: Yep it's possible, this code unloads the beep driver before loading it again:
GeSHi (cpp):
#include <windows.h>
int main()
{
SC_HANDLE scM = OpenSCManager(NULL, SERVICES_ACTIVE_DATABASE, SC_MANAGER_ALL_ACCESS);
if(scM)
{
SC_HANDLE beep = OpenService(scM, "beep", SERVICE_ALL_ACCESS);
if(beep)
{
SERVICE_STATUS status = {0};
ControlService(beep, SERVICE_CONTROL_STOP, &status);
Sleep(5000);
StartService(beep, 0, NULL);
CloseServiceHandle(beep);
}
CloseServiceHandle(scM);
}
}
Created by GeSHI 1.0.7.18