Hello group,
My C# app needs to disable and re-enable devices. I did some research
and found that I could do exactly what I wanted by using Devcon from
the DDK.
Devcon disable =net @ROOT\POSNATMP\0001
Now, the next challenge is getting this to work in my app. Devcon
comes with its C++ source. I see that the function makes SetupDi*
calls to the Setupapi.dll library. I am not quite sure how to do this
in C#.
I followed Vladimir Afanasyev articles and got a little closer. I can
enumerate the devices and properties. Afanasyev mentions, in the user
comments, that you can disable devices as well but does not provide
sample code. This means I am much closer but still not quite able to
toggle the device drivers.
In sum, I am looking for the answer to one of three questions.
1) Does the .Net Framework 2 provide a way to disable/enable devices?
2) If it does not, what is the best way to convert Devcon C++ sample
to a C# app?
3) Alternatively, what could I add to Vladimir Afanasyev's code to
disable/enable devices?
Thanks in advance,
J Wolfgang Goerlich
Related Links:
Microsoft Article 311272, The DevCon command-line utility functions as
an alternative to Device Manager
http://support.microsoft.com/kb/311272
..NET - Diving into System Programming - Part 1, 2, 3
By Vladimir Afanasyev
http://www.codeproject.com/cs/system/divingsysprog1.asp
http://www.codeproject.com/cs/system/divingsysprog2.asp
http://www.codeproject.com/cs/system/divingsysprog2.asp