Click here to Skip to main content
15,942,847 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I need to create a C++ console program that executes without exhibiting a window of any kind. All processing should be done in the background without any screen drawing.

What I have tried:

I tried to hide the console window but it always flashes the console screen when the program is ran.
Posted
Comments
Shao Voon Wong 30-Jan-24 5:05am    
Hi Eduardo, I have posted a tip to answer your question on converting console app not to show console here: https://www.codeproject.com/Tips/5376609/Cplusplus-Convert-Console-Project-to-Non-Console

A better choice would be a Windows Service since they have no UI at all.

Trying to do this as a normal, user launchable app seems ... suspicious.
 
Share this answer
 
You can create regular windows application not the console application, just do not create any dialogs and proceed like you do as you had the console application.
There will be just linker configuration change and the function WinMain instead of main.
You can look at the C++ samples of my article which has the similar implementation:
https://www.codeproject.com/Articles/5361060/Tracing-and-Logging-Technologies-on-Windows-Part-1

Regards,
Maxim
 
Share this answer
 
It's not clear what you're trying to achieve. If you want to create a service, then you should follow the advice in Solution 1. If you're trying to create a commandline utility, like copy for example, then what you're doing is probably what you want. I'm guessing that you're seeing the command window open when you run the program within the IDE. This is normal, as the IDE needs to create a terminal environment for the program to run in. Try running the program directly from a command window. It should do it's thing and return to the commandline prompt without showing a new console window.
 
Share this answer
 
Comments
PIEBALDconsult 24-Jan-24 13:11pm    
Might be running by double-clicking in Windows Explorer.
Use a WinMain without the window creation
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900