I'm working on a program that uses the enable and disable devices function of the devcon.exe. It works well but I don't think I can legally package a copy of the devcon.exe with the program. I have the source of the program, it's in C++ or C# not sure which I have no experience with and kind of C. Keeping that don't know C thing in mind; how do I make a DLL out of the devcon.exe code with only the enable and disable device functions in it? Also this DLL is for use in a vb.net program if that makes any difference. (If I need to put the entire exe into the DLL thats fine, I just thought that just having the two function in it would make it easier to make.)
devcon.exe download here
devcon.exe source download here
devon.exe uses cfgmgr32.dll and setupapi.dll to do the actual work - instead of turning devcon.exe into a dll - use the dlls it uses instead.
To call from a 32 bit vb.net program, you need to use pinvoke, a IJW (it just works) technology that's part of .NET that handles calling Win32 dlls from .NET by declaring a DLL import.
Most of the time, you can look on http://pinvoke.net for the proper declaration. So for example, SetupDiEnumDeviceInfo can be declared like:
Private Declare Auto Function SetupDiEnumDeviceInfo Lib "setupapi.dll" ( _
ByVal DeviceInfoSet As Integer, _
ByVal MemberIndex As Integer, _
ByRef DeviceInfoData As SP_DEVINFO_DATA) As Boolean
The pinvoke.net entry for SetupDiEnumDeviceInfo
also has an example for how to call it.
You'll have to learn the setupapi but I think that will be much easier than turning devcon.exe into a DLL, which would still require pinvoke to call.