2

I have an app which is using DEVCON to do the following;

  • Get device status
  • Enable
  • Disable
  • All of the above based on compatible id's.

How can I do the same without using DEVCON at all? I still need the same functionality listed above.

I have looked into This question and answer but I need to tailor it more towards the criteria above. It also needs to work on x86, x64 and XP+.

Can anyone help with this?

Community
  • 1
  • 1
Pickled Egg
  • 123
  • 3
  • 12

1 Answers1

1

To do it from C#, you'd have to pinvoke Windows Setup APIs

This link has an example in C of how the Setup APIs can be used to enumerate devices.

And interestingly enough, there is a Powershell module available on TechNet for Device Management.

If the license allows it, you could take a peek at the implementation, which is in .Net.

Vikas Gupta
  • 4,455
  • 1
  • 20
  • 40