I am trying to automate DevCon's functionality into a C# program. Instead
of accessing DevCon.exe directly using Process threads, I want to instead
call the commands directly from my project, and therefore eliminate having to
distribute DevCon.exe with my application.
I initially set this question in a .NET forum, and a responder suggested I
compile the source code into a DLL, and import that into my C# project. I'm
new to C++, and I am not sure the best way to do this.
I'd appreciate any assistance.
That's exactly why the source code for devcon is included in the DDK. It's
a sample. You're supposed to use the code as a recipe. The license
doesn't allow you to ship the executable with your app.
>I initially set this question in a .NET forum, and a responder suggested I
>compile the source code into a DLL, and import that into my C# project. I'm
>new to C++, and I am not sure the best way to do this.
Surely you aren't trying to incorporate the ENTIRE functionality of devcon
into your C# program. You just need a couple of functions, right? All you
need to do is write P/Invoke headers for the SetupDi calls you need, and
convert the C++ code to C#. It's mostly a 1-to-1 conversion.
--
Tim Roberts, ti...@probo.com
Providenza & Boekelheide, Inc.
I've never used P/Invoke before. Could you give me a quick example on how
to call one of the functions you mentioned in my C# code?
Thanks!
"Tim Roberts" wrote:
> .
>
It's hard to imagine that any relatively experienced C# programmer has
never had to call into a DLL to use one of the Win32 APIs. It's very, very
common. There's even a website that gives you the PInvoke declaration for
all of the Win32 APIs -- www.pinvoke.net.
http://www.netomatix.com/Development/SetupApi.aspx
http://www.drdobbs.com/article/printableArticle.jhtml?articleId=184416423&dept_url=/windows/
http://bytes.com/topic/c-sharp/answers/656850-disabling-devices-calling-setupapi-dll-converting-devcon-c
http://jo0ls-dotnet-stuff.blogspot.com/2009/01/enabledisable-device-programmatically.html
But thanks for the links. pinvoke.net has proved extremely useful.
"Tim Roberts" wrote:
> .
>