Click to See Complete Forum and Search --> : Launch an application with no window that will appear in the applications tab
eranben
March 22nd, 2009, 08:18 AM
Hello,
here's one for you:
I am launching an application using CerateProcess with
CREATE_NO_WINDOW flag.
I don't want a window because I launch several hundreds of these
processes.
I do, however, want the processes to appear in the applications tab of
the task manager so I can terminate them gracefully (end process kills
them immediately while end task sends a signal I can catch and release
resources).
So far, I found that in order for an application to be on the
applications tab it needs to be in the foreground. Is there a way to
have an application with no window run in the foreground?
Any other suggestion achieving the same goal of numerous processes
launched, with little memory usage and without opening cluttering
windows, that can be terminated with end task will be welcomed.
Thanks
Eran
nightpwn2
March 22nd, 2009, 12:17 PM
Can't you launch the process, then send SW_HIDE to the Window Class to make it hide but still showing in the task manager?
I was searching a part of your question, and I got this as one of the answers, skimming through it sounds like it can fix your bottle neck.
http://www.ddj.com/windows/184405755
~~~Matt
eranben
March 23rd, 2009, 01:53 AM
Thanks Matt,
Closing the window is my fallback but I don't really want to do this because I don't want to involve window handles and pure WinAPI objects as the code will be cross platform eventually (using ACE).
Another option was to leave the process in the back and terminate it using end process from task manager. Do you know of a way to catch this signal? I haven't found one.
Eran
_Superman_
March 23rd, 2009, 05:11 AM
If there is no Window, how do you expect Task Manager to send you a message.
eranben
March 23rd, 2009, 05:34 AM
That's exactly the question:
Does an application have to have a window in order to appear in the applications tab?
It appears in the processes tab even with no window
Igor Vartanov
March 24th, 2009, 04:27 AM
That's exactly the question:
Does an application have to have a window in order to appear in the applications tab?Taskbar (http://msdn.microsoft.com/en-us/library/aa511446.aspx)
A quote:
Appearing on taskbar
The system determines if a window is displayed on taskbar as follows:
A window has a taskbar button if:
The window is visible (ShowWindow was called with SW_SHOW).
The window doesn't have an owner or was created with the WS_EX_APPWINDOW extended style.
A window doesn't have a taskbar button if:
The window is hidden (ShowWindow was called with SW_HIDE).
The window has an owner or was created with the WS_EX_TOOLWINDOW extended style.
So while developers don't have direct control over the windows that have taskbar buttons, they do have indirect control through window attributes.
Every instance of a program displayed on the desktop has a taskbar button that represents the program's primary window. A program may have secondary modal windows (such as modal dialog boxes), or modeless windows (such as modeless dialog boxes, palette windows, and undocked task panes and toolbars). Through the primary window's taskbar button, the primary window along with all its secondary windows are minimized, restored, and brought to the top level as a group. Certain modeless windows have their own taskbar buttons for direct access.
It appears in the processes tab even with no windowYeah, sometimes it does. When its window is invisible. :D
srelu
March 29th, 2009, 08:01 PM
Don't use the task manager. Define a combination of keys you use to terminate the process. From a timer, read the status of the keyboard periodically. If that combination of keys is pressed, start waiting for a process identifier to be typed. Then exit the desired process.
You can even consider a console application managing all of your processes.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.