Solved

Console-less program

Posted on 1998-07-22
15
419 Views
Last Modified: 2012-06-27
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?
0
Comment
Question by:gemme
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
  • 4
15 Comments
 
LVL 8

Expert Comment

by:trestan
ID: 1168346
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.
0
 

Author Comment

by:gemme
ID: 1168347
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.
0
 
LVL 8

Expert Comment

by:trestan
ID: 1168348
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.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 22

Expert Comment

by:nietod
ID: 1168349
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.
0
 
LVL 22

Expert Comment

by:nietod
ID: 1168350
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.)
0
 

Author Comment

by:gemme
ID: 1168351
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.
0
 
LVL 8

Expert Comment

by:trestan
ID: 1168352
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.
0
 
LVL 22

Expert Comment

by:nietod
ID: 1168353
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.
0
 

Author Comment

by:gemme
ID: 1168354
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?
0
 
LVL 22

Expert Comment

by:nietod
ID: 1168355
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.
0
 
LVL 8

Expert Comment

by:trestan
ID: 1168356
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?
0
 
LVL 8

Expert Comment

by:trestan
ID: 1168357
Pls READ our comments.
0
 
LVL 22

Expert Comment

by:nietod
ID: 1168358
>> 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.
0
 

Author Comment

by:gemme
ID: 1168359
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.
0
 
LVL 8

Accepted Solution

by:
trestan earned 100 total points
ID: 1168360
I think you should post another question and indicate To nietod to let him also get awards, if you like.
0

Featured Post

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

695 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question