Solved

Console-less program

Posted on 1998-07-22
15
416 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
Independent Software Vendors: 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

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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Microsoft C++ code failing in executable that worked 9 136
Safe conversion? 4 84
object oriented programming comparison 5 92
Why  my code (program) build with old compiler? 11 140
When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
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.

734 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