Avatar of tullhead
Flag for United States of America

asked on 

How to convert a MFC application with a GUI to a GUI-less executable?

I have a desktop application written Microsoft Visual C++ using Visual Studio 2017.  Its a single-doc MFC application.   Rather large, developed over the past 15+ years.  Now I want to be able to do something different: normally, of course, the application starts up and shows its GUI on the screen.  I want to add a mode (will have the App check for the presence of a certain file at start up) in which it does not pop its GUI up.  Ultimately, I'd like to have the ability to run it either A) with its GUI as usual, or B) as a GUI-less executable, probably in a windows service.  The app contains a socket-based message system that listens for commands and sends responses -- so when it is running in GUI-less mode, it will be another program talking to it over this socket channel in order to have it do useful work.

So, how to do this?   Maybe forget about the windows service idea for now -- just simply how to start my application and have it run without ever popping a GUI?   The structure, due to MFC, with the Doc, the View, the InitInstance code, the MainFrame class -- all that stuff is kind of mysterious to me.  I just used the structure that the MFC wizard gave me (when I first created this App back in Vis Studio version 6!).  Now it seems I may need some understanding of how to launch the system, but without Mainframe and the View popping up, etc.  Some of the Apps actions occur due to "OnTimer" code which might be on a dialog class -- so it seems to me I'd have to rework that perhaps -- there won't be a windows message loop running, so maybe OnTimer stuff won't run?

Thanks if you can give me some hints to try.
C++* MFCMicrosoft Visual Studio

Avatar of undefined
Last Comment

8/22/2022 - Mon