Program No Console Window?

Started by
6 comments, last by jpetrie 17 years, 6 months ago
How do I create a program in C++ that runs in the background without a console window. Do I need to resort to windows programming and not show the window?
Advertisement
I believe I saw a command for it at one point, but sadly I dont know what it is.

Do you want it listed in the task bar? or that little spot next to the clock ? or only in the task manager?

Sorry I can't help you further, but if you answer those questions maybe someone will be able to help you more.
Quote:
Do I need to resort to windows programming and not show the window?


Yes, you'll need to create a "Win32" project instead of a console project (this will set up the appropriate project options to omit the automatic linking with the CRT boot code that sets up the console window, and a couple other things; you can change this in an existing project if you know what to look for).

Then just don't create a window.
I would like to just have it run in the taskmanager for now.

Also i was trying to use getch to read ctrl` or ctrl~ and it doesn't work, how do I read these keys.
** hack alert

Interestingly this was on windows support page to find a console window. To me its not a good idea to do but would work for existing console apps.

http://support.microsoft.com/kb/Q124103/

Then when you have the hwnd id, call ShowWindow( hwnd, SW_HIDE);
Im not hacking I just want to create an application that runs in the background and when I press ctrl~ it runs the system cmd.exe file to bring up a console.
This was done on an appaday and I thought I'd like to try to do it in C++ sounds simple right, not really.
thnks
Oh, then actually that code wouldn't be too too bad of a hack.

You could set up the app to hide initially, intercept windows calls in the background for key events, then show the console again.

The reason I say its a hack is that the code does a change of the console title window and then does a search for that specific window title, but given that it changes the name to something "unique", it provides a simple way to do it.
Like I said, make a Windows app, but just don't create a window.

Now, it's going to be trickier to install the hooks you need to intercept keypresses regardless of whether or not the app has focus. You'll have to search around on the MSDN for the information.

(iminyourbrain mean "hack" in the sense that his suggestion, while it would probably work, is very inelegant and not guaranteed to work consistently, often, or at all).

This topic is closed to new replies.

Advertisement