I've tried invoking UpdateDriverForPlugAndPlayDevices three different ways. Here they are:
[DllImport("newdev.dll", CharSet = CharSet.Ansi, SetLastError = true)]
public static extern bool UpdateDriverForPlugAndPlayDevices(
IntPtr hwndParent,
[MarshalAs(UnmanagedType.LPWStr)] string HardwareId,
[MarshalAs(UnmanagedType.LPWStr)] string FullInfPath,
uint InstallFlags,
ref bool bRebootRequired);
[DllImport("newdev.dll", SetLastError = true, CharSet = CharSet.Auto)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool UpdateDriverForPlugAndPlayDevices(
[In, Optional] IntPtr hwndParent,
[In] string HardwareId,
[In] string FullInfPath,
[In] uint InstallFlags,
[Out, Optional] bool bRebootRequired
);
[DllImport("newdev.dll", SetLastError = true)]
public static extern bool UpdateDriverForPlugAndPlayDevices(
IntPtr hwndParent,
string HardwareId,
string FullInfPath,
uint InstallFlags,
ref bool bRebootRequired
);
Regardless of which of these I call, the returned result is false, and the following call to Marshall.GetLastWin32Error()
gives an error code of -536870347. I've searched and searched and not found any such error code.
I feel like the problem is with the way I'm defining the function because I can pass nonsensical parameters to my call to UpdateDriverForPlugAndPlayDevices()
and I still get the same error code.
The previous calls leading up to this work fine, I'm using pinvoked calls to SetupDiGetClassDevsW()
, SetupDiEnumDeviceInfo()
, SetupDiGetDeviceRegistryProperty()
and SetupCopyOEMInf()
and they all act in the expected ways.
Can someone tell me what this error means, or what I'm doing wrong? Thank you!