[DllImport("setupapi.dll", SetLastError=true)]
static extern bool SetupDiGetDeviceInstallParams(IntPtr hDevInfo, ref SP_DEVINFO_DATA DeviceInfoData, ref SP_DEVINSTALL_PARAMS DeviceInstallParams);
[StructLayout(LayoutKind.Sequential)]
internal struct SP_DRVINFO_DATA
{
public Int32 cbSize;
public Int32 DriverType;
public UIntPtr Reserved;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=256)]
public String Description;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=256)]
public String MfgName;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=256)]
public String ProviderName;
public System.Runtime.InteropServices.ComTypes.FILETIME DriverDate;
public Int64 DriverVersion;
};
[StructLayout(LayoutKind.Sequential)]
internal struct SP_DEVINSTALL_PARAMS
{
public Int32 cbSize;
public Int32 Flags;
public Int32 FlagsEx;
public IntPtr hwndParent;
public IntPtr InstallMsgHandler;
public IntPtr InstallMsgHandlerContext;
public IntPtr FileQueue;
public IntPtr ClassInstallReserved;
public int Reserved;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=260)]
public string DriverPath;
}
<DllImport("setupapi.dll")> _
Public Shared Function SetupDiGetDeviceInstallParams(ByVal hDevinfo As Integer, _ 'Alternate ByVal hDevInfo as IntPtr
ByRef DeviceInfoData As SP_DEVINFO_DATA, _
ByRef DeviceInstallParams As SP_DEVINSTALL_PARAMS _
) As Boolean
End Function
<StructLayout(LayoutKind.Sequential)> _
Public Structure SP_DEVINFO_DATA
Public cbSize As Integer
Public ClassGuid As Guid
Public DevInst As Integer
Public Reserved As IntPtr
End Structure
<StructLayout(LayoutKind.Sequential, pack:=1)> _
Public Structure SP_DEVINSTALL_PARAMS
Public cbSize As Integer
Public Flags As Integer
Public FlagsEx As Integer
Public hwndParent As IntPtr
Public InstallMsgHandler As IntPtr
Public InstallMsgHandlerContext As IntPtr
Public FileQueue As IntPtr
Public ClassInstallReserved As IntPtr
Public Reserved As Integer
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=MAX_PATH)> _
Public DriverPath As String
End Structure
Do you know one? Please contribute it!
None.
Please add some!
' see if device needs reboot
Dim devParams As SP_DEVINSTALL_PARAMS
devParams.cbSize = Marshal.SizeOf(devParams)
If Win32.SetupDiGetDeviceInstallParams(hDevInfo, DeviceInfoData, devParams) Then
If (devParams.Flags And Win32.DI_NEEDRESTART) = Win32.DI_NEEDRESTART OrElse (devParams.Flags And Win32.DI_NEEDREBOOT) = Win32.DI_NEEDREBOOT Then
Return True
End If
Else
Return False
End If