Link to home
Start Free TrialLog in
Avatar of gemme
gemme

asked on

Console-less program

I want to create a small app that does not use a console and does not display a console.  Any idea how to do this using visual c++ 5.0?
Avatar of trestan
trestan
Flag of Canada image

So you need to create a Windows application. Since you use VC5, you can create one easily with application wizard. Or when you use CreateProcess to launch a console application, you can use the hide window option so that the console window will not appear. See the function CreateProcess in online help.
Avatar of gemme
gemme

ASKER

I do not want to create a windows application.  I want to create an exe that has no console.  I know how to use the app wizard and  CreateProcess but... what I want to do is have this small program signal an event to another application running.  This small program should not be seen by the user.  It should be able to be started from a batch file.  I have this running in a application created with the app wizard but when you run it.. it shows a blank console while it is running.
Did you use createprocess to launch the program? You set the si.wShowWindow = SW_HIDE; in STARTUPINFO si; Then the window would not show. Other functions: exec, spawn, system will show the console window.
As trestan said, A windows application that doesn not create any windows will work exactly like you want it.  Your code won't even need significant changes if any at all.

You canot do this using a console program.  The OS will start a console for a console application, there is no getting around it.  

However it is possible for a console application to be started with a minimized console window, if you insist on going that route.  But the user could "open up" the console window that way.
trestan's new answer (it wasn't there when I started mine) is like what I was suggesting when I said you can start a console with a minimized window, although he is suggesting starting it with a  hidden window.  That is better, assuming that works.  (The minimized window approach does work.)
Avatar of gemme

ASKER

I will not be starting the program.  This program will be started from a batch file.  It is going to be used for sychronize a non windows app with my windows app so I chose to use an event.  All this program will do will pulse the event I have created. I cannot have it started from a createprocess call because the batch file cannot use createprocess.
If the program to be started in the batch file is a console application, you have no way to conseal the black window unless you make it wrapped. You can make another Windows application to launch the program. Hide both windows of them. Or if you use NT, you can make the program a NT service.
Gemme, you still haven't provided any information to suggest that trestan's original suggestion, using a windows program, won't work.  With the information provided, that seems like the best answer.
Avatar of gemme

ASKER

Let me try to explain clearer.  
I have a windows application that is controlling some hardware.  At some point I need to have a dos based program change some setups on the hardware so I need my program to suspend until the dos based program is done.  I have chosen to have the dos based program execute a batch file that among other things, will execute a program that only pulses an event to wake up my windows app to start controlling again.  This program I would like to NOT have any appearance to the operator of the machine.  It should just start, pulse the event and quit, no interface at all and being started from a batch file, cannot use CreateProcess.  I have already created this app with the app wizare (win32 console app) but it show a console when it runs. I am not sure this is going to be easy if I use VC5.  Any other suggestions?
Okay.  But there is no reason listed there that explains why the "pulse" application has to be a console process.  A windows application would handle your needs just as well and would not have a console.  You probably don't need to make a single change to the code other than renaming main to winmain (and chaning the parameters), then just compile it as a windows application.
Only make your progam in windows application then you can hide your window. Otherwise, you try to detect the end of batch file (the special message) in your windows application. But the former is easier. So, why not?
Pls READ our comments.
>> Only make your progam in windows application then you can hide your window
Easier than that. Just don't create a window!  A windows program doesn't have to have a window and it doesn't have to have a message loop.  Just write it like a console application with a winmain() instead of main() and it will work fine.
Avatar of gemme

ASKER

I understand.  My mistake was using win32 console application from the app wizard.  Thanks for your patience.  This box does not give my the choice of awarding points so I am not sure how to do that either.
ASKER CERTIFIED SOLUTION
Avatar of trestan
trestan
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial