Skip to content

Commit

Permalink
Fixed bug, added crude test
Browse files Browse the repository at this point in the history
  • Loading branch information
nefarius committed Jul 4, 2024
1 parent e089794 commit 8ff8d90
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
21 changes: 21 additions & 0 deletions App/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,27 @@
using Nefarius.Utilities.DeviceManagement.Drivers;
using Nefarius.Utilities.DeviceManagement.PnP;

Guid DeviceInterfaceGuid = Guid.Parse("{399ED672-E0BD-4FB3-AB0C-4955B56FB86A}");
bool rebootRequired = false;
int instance = 0;
// uninstall live copies of drivers in use by connected or orphaned devices
while (Devcon.FindByInterfaceGuid(DeviceInterfaceGuid, out PnPDevice dev, instance++, false))
{
try
{
dev.Uninstall(out bool reboot);

if (reboot)
{
rebootRequired = true;
}
}
catch (Exception ex)
{

}
}

DriverStore.RemoveDriver(@"C:\temp\nonexistent");

const string instanceId = @"USB\VID_054C&PID_0CE6&MI_03\9&DC32669&3&0003";
Expand Down
2 changes: 1 addition & 1 deletion src/PnP/PnPDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ public unsafe void Uninstall(out bool rebootRequired)

uint iFlags = PInvoke.DIGCF_ALLCLASSES;

if (_locationFlags.HasFlag(DeviceLocationFlags.Normal))
if (_locationFlags == DeviceLocationFlags.Normal)
{
iFlags |= PInvoke.DIGCF_PRESENT;
}
Expand Down

0 comments on commit 8ff8d90

Please sign in to comment.