tags:

views:

144

answers:

2

Hi , i got to do a task that is to find out process /exe/application running in the background. ie:the process is running but do not have any UI/ Window visible although its an windows GUI application . i thot of reading EXEheader. The header contains a field called 'Subsystem'and application is to run under and the type of interface it requires. but it returns Windows GUI and it is so. but i want teo detect if that application haves any window or not. also this application is not a service as if it is a service i can easily read the info. i will be glad if any of you genious put some light on the pronblem stated.

Warm Greetings.. Sarfu

+3  A: 

If I understand your question correctly, you want to know if a running application has any visible windows.

To do this, you can call EnumWindows to get all top-level windows. For each window, call GetWindowThreadProcessId to get the process ID and GetWindowLong(hwnd, GWL_STYLE) to get the window style. Test the style for WS_VISIBLE to see if the window is visible. Run through all the windows and see if your process owns a visible one. If you don't have the process ID, you can get them all with EnumProcesses.

interjay
No, that doesn't work. An application might also have no windows at all, e.g. simply because it hasn't called `CreateWindow` yet.
MSalters
... in which case it is (at that time) a windowless application. You can't do better than that unless you know a way to predict the future.
interjay
A: 

The "subssytem" GUI doesn't tell you that the application has a window. In fact, the opposite is closer to the truth. A console application gets a console window. A GUI app is responsible for creating its own windows, if and when it needs them. A GUI process that hasn't called CreateWindow() won't have any windows.

Apparently, you do know the executable you're looking for. In that case, call EnumProcesses() to find all processes, and for each process call EnumProcessModules(). On Windows, "modules" are DLLs and EXEs. Each process will have exactly one EXE module. So, if the one EXE module of any process is the executable you're looking for, then your application is running.

MSalters