The DiInstallDriver function preinstalls a driver in the driver store and then installs the driver on devices present in the system that the driver supports.
BOOL DiInstallDriverA( HWND hwndParent, LPCSTR InfPath, DWORD Flags, PBOOL NeedReboot );
A handle to the top-level window that DiInstallDriver uses to display any user interface component that is associated with installing the device. This parameter is optional and can be set to NULL.
A pointer to a NULL-terminated string that supplies the fully qualified path of the INF file for the driver package.
A value of type DWORD that specifies zero or DIIRFLAG_FORCE_INF. Typically, this flag should be set to zero.
If this flag is zero, DiInstallDriver only installs the specified driver on a device if the driver is a better match for a device than the driver that is currently installed on a device. However, if this flag is set to DIIRFLAG_FORCE_INF, DiInstallDriver installs the specified driver on a matching device whether the driver is a better match for the device than the driver that is currently installed on the device.
A pointer to a value of type BOOL that DiInstallDriver sets to indicate whether a system is restart is required to complete the installation. This parameter is optional and can be NULL. If the parameter is supplied and a system restart is required to complete the installation, DiInstallDriver sets the value to TRUE. In this case, the caller must prompt the user to restart the system. If this parameter is supplied and a system restart is not required to complete the installation, DiInstallDriver sets the value to FALSE. If the parameter is NULL and a system restart is required to complete the installation, DiInstallDriver displays a system restart dialog box. For more information about this parameter, see the following Remarks section.
DiInstallDriver returns TRUE if the function successfully preinstalled the specified driver package in the driver store. DiInstallDriver also returns TRUE if the function successfully installed the driver on one or more devices in the system. If the driver package is not successfully installed in the driver store, DiInstallDriver returns FALSE and the logged error can be retrieved by making call to GetLastError. Some of the more common error values that GetLastError might return are as follows:
||The caller does not have Administrator privileges. By default, Windows requires that the caller have Administrator privileges to preinstall a driver package in the driver store.|
||The path of the specified INF file does not exist.|
||The value specified for Flags is not equal to zero or DIIRFLAG_FORCE_INF.|
||The calling application is a 32-bit application that is attempting to execute in a 64-bit environment, which is not allowed. For more information, see Installing Devices on 64-Bit Systems.|
DiInstallDriver performs the following operations:
- Preinstalls the driver package in the driver store. If there is an instance of the same driver package already preinstalled in the driver store, DiInstallDriver first removes that instance and then adds the new instance of the driver package to the driver store.
- Enumerates devices that are present in the system.
- If Flags is equal to zero, installs the driver on a device only if the specified driver is a better match for the device than the driver that is currently installed on the device.
- If Flags is equal to DIIRFLAG_FORCE_INF, installs the driver on a device regardless of whether the driver package is the better match to the device than the driver that is currently installed on the device.
- The application must call DiInstallDriver several times to complete an installation. In this case, the application should record whether a TRUENeedReboot value is returned by any of the calls to DiInstallDriver and, if so, prompt the user to restart the system after the final call to DiInstallDriver returns.
- The application must perform required operations, other than calling DiInstallDriver, before a system restart should occur. If a system restart is required, the application should finish the required operations and then prompt the user to restart the system.
- The application is a class installer, in which case, the class installer should set the DI_NEEDREBOOT flag in the Flags member of the SP_DEVINSTALL_PARAMS structure for a device.
|Windows version||Available in Windows Vista and later versions of Windows.|
|Header||newdev.h (include Newdev.h)|