I’ve created a program that has two projects: a windows UI and an “engine”. I would like to make it so that the user can execute the program from a command prompt passing in some arguments and the engine will automatically execute them and spit out the results. OR the user can launch the UI and choose all of their options via dropdown lists and such and then click a button to tell the engine to do it’s work.
I actually already have it working using something I found a long time ago, but I’m trying to see if there’s an easier way. The way I found involves adding a Win32 class and creating externals to AllocConsole, FreeConsole, and AttachConsole from kernel32.dll.
Is there an easier way? Thanks.
I’ve created a program that has two projects: a windows UI and an engine.
Share
it’s simple, make your windows forms application and in the
Mainmethod check the command line parameters and in case your parameters are there, instead of callingsimply call your engine and start processing.
it’s important to code your engine properly and have also the UI using the same engine when the user is starting those commands from the user interface, so to avoid any useless code duplication.
we use this approach in many programs and we are satisfied, if you do not call
Application.Run(...)your program will simply terminate when theMainmethod ends.