简体   繁体   中英

Make Non-GUI server application in Visual Studio

I did a project of Server Socket in Visual studio in C++ MFC based. Now, after debugging the project, server GUI opens, then after clicking on the CONNECT button on server GUI, you can connect the clients to that server and so on.

Now I want to use that server exe file in some other computer. So that whenever that computer starts, that server exe automatically starts. so for this i need to disable the connect button, so that after debugging, server GUi opens and connected automatically. But i don't want that server GUI opens in another computer in autostart as well. i want to disable that server GUI.

I got an idea of modalless dialog to work on it. Is it good or what approach should I use ?

You probably want to separate GUI part and server part of your application. Ideally, if your server is actually a server, you should start it as service . Then you will have separate GUI tool to control it.

Another approach is to have command line argument that determines whether server should be started with GUI enabled or disabled.

The only professional and stable solution of such an application is, to splitt it in a console part, which you put under the control of service control and a gui part wich the user can start when he wants.

I tried solutions like yours and so I can tell you from my own experience, that you will face a lot of problems.

However, a possible solution would be to hide the window and lay the app down to systray and this is a very interesting discussion about hinding windows.

Additionaly I have two good advices in case of MFC:

  1. Never ever just "copy-past" code without to know what MFC is doing in the background (Win32api).
  2. Do not use MFC. Have a closer look at QT or wxWidges when you need windows, to shortcut encapsulation of win32api also have a look at boost library. It is realy worth the time you spend on!

Good luck!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM