Solved

Console-less program

Posted on 1998-07-22
15
397 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
 
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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

758 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now