I am looking for way to disable a system device (either USB or internal) in C#.NET given either the PID & VID or the device name.
After searching I found Hardware Helper Library for C# on CodeProject.
But I need something that will work on XP, Vista & Windows 7 (both x86 and x64 operating systems)…the project I linked only works with XP and Vista x86…even when running the application with administrator privileges.
Does anyone know of a solution that would work on all operating systems?
Best Answer
Looks like there were two things in drf's version that were giving you trouble. Your x64 problem was caused by SP_DEVINFO_DATA having a uint where an IntPtr was needed. The second is that the SetupDiGetDevicePropertyW function is Vista+ and won't run on XP.
Here's a version with those two issues corrected. I tested as x86 and AnyCPU on XPx86 and Win7X64.