From: santapanda on 26 Mar 2010 12:41 Hello, 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.
From: Tim Roberts on 26 Mar 2010 23:43 santapanda <santapanda(a)discussions.microsoft.com> wrote: > >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. 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, timr(a)probo.com Providenza & Boekelheide, Inc.
From: santapanda on 29 Mar 2010 09:13 Thanks Tim, 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: > santapanda <santapanda(a)discussions.microsoft.com> wrote: > > > >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. > > 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, timr(a)probo.com > Providenza & Boekelheide, Inc. > . >
|
Pages: 1 Prev: Device power state change notification. Next: Debugging using VM 2007 |