Solved

Console-less program

Posted on 1998-07-22
15
405 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
  • 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
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.

778 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