Solved

function needed similar to FreeConsole()

Posted on 1998-08-03
11
330 Views
Last Modified: 2010-04-02
Hi,
I have the problem that a Console Application
should disappear from the screen. I can't use
FreeConsole(), since my program is using
StdInput und StdOutput handles to redirect the
output of its child. The best is to only show
the process in the Systray. (the process should
run as a service, if I call FreeConsole() then
the redirection fails).

Does anyone have a solution for this problem ?
0
Comment
Question by:boyracer
  • 6
  • 4
11 Comments
 
LVL 8

Expert Comment

by:trestan
ID: 1169283
Use CreateProcess() function to execute the application. Then the console window can be hiden. Use CreatePipe to redirect the output the created pipe. Then ReadFile to take the output from the file. I have used this method. And the variable of the pipe should be local to the function.
0
 

Author Comment

by:boyracer
ID: 1169284
Maybe I was not specific enough. It is the parent window
which should disappear.
0
 
LVL 22

Expert Comment

by:nietod
ID: 1169285
I don't know enough about console window applications.  Can you access the window handle?  If so, just use ShowWindow() with a SW_HIDE parameter.
0
 
LVL 22

Expert Comment

by:nietod
ID: 1169286
I can't find any way to access a console window's window handle?  were you able to?  If not, one solution that will work is to use SetConsoleWindowInfo() to position the console window at coordinates that are off the screen.  If you want the make the window vissible again, you can return it to its original coordinates which you would obtain using GetConsoleScreenBufferInfo().

The only problem I can see with this, is that the console will still appear on the task bar.
0
 
LVL 22

Expert Comment

by:nietod
ID: 1169287
What is happening with this problem?  Have you found a solution?  Did you try the one I suggested?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:boyracer
ID: 1169288
yes,
the problem is that the process shows up on the taskbar.
I am now thinking about moving to the win32 api where I have
an example how to put the task in the systray.
however I don't know if my redirection of pipes fails.
another message I received was that I can use FreeConsole(),
but have to modify the handles. I did not get that to work
either :-(

0
 
LVL 22

Accepted Solution

by:
nietod earned 200 total points
ID: 1169289
I don't know why I didn't think of this before!
You can use FindWindow() to get a handle to the console window.

Then you can use ShowWindow() with SW_HIDE to hide the window.

0
 

Author Comment

by:boyracer
ID: 1169290
All right !
Since I am at a Unix machine at the moment I will try
it this evening. But it sounds good.

markus

0
 
LVL 22

Expert Comment

by:nietod
ID: 1169291
The window class you need to search for seems to be "tty" in windows 95 and "ConsoleWindowClass" in window NT.  If you want to be sure to hide the right window, you can use SetConsoleTitle() to be sure that the console window has a very unique name so you don't accidentally find another window and hide that one instead.
0
 

Author Comment

by:boyracer
ID: 1169292
All right !
Since I am at a Unix machine at the moment I will try
it this evening. But it sounds good.

markus

0
 
LVL 22

Expert Comment

by:nietod
ID: 1169293
Never accept an answer without trying it first!   The general approach will work, but who knows what little problems might appear that will cause the solution to be insufficient.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
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 goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

919 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