闲话少说,进入正题。查找EVC的帮助,发现函数ActivateDevice()可用来加载驱动程序。而这个函数的使用是相当简单的。我就不多说了,贴上一段帮助最能说明问题。当然,你也可以用ActivateDeviceEx()。
HANDLE ActivateDevice (
LPCWSTR lpszDevKey,
DWORD dwClientInfo
);
Parameters
lpszDevKey
[in] Pointer to the registry path string of the device's driver key under HKEY_LOCAL_MACHINE. A driver key contains the DLL name, the device prefix, friendly name, and other device information.
dwClientInfo
[in] Data that will be stored in the device's Active key in the ClientInfo value. The registry path to the driver's Active key is passed in as the context parameter to the device's XXX_Init function. The value in dwClientInfo is stored in the registry before XXX_Init is called.
Return Values
On success, ActivateDevice returns a handle to the device that can be used in subsequent calls to DeactivateDevice.
Remarks
This function is superseded by ActivateDeviceEx.
ActivateDevice loads a device driver. ActivateDevice reads the registry key specified in lpszDevKey to get the DLL name, device prefix, index, and other values. Next it adds the device to the active device list in the registry branch HKEY_LOCAL_MACHINE\Drivers\Active, and stores the relevant values there. If no device index was specified in the key named in lpszDevKey, then it assigns a free index. Then it loads the device driver DLL in the process space of the Device Manager. Then it broadcasts a WM_DEVICECHANGE message for the new device and triggers a NOTIFICATION_EVENT_DEVICE_CHANGE event in the application notification system to notify applications of the presence of the new device.
”,