x
This website is using cookies. We use cookies to ensure that we give you the best experience on our website. More info. That's Fine
HPC:Factor Logo 
 
Latest Forum Activity

New developer question

vcaretr Page Icon Posted 2005-07-28 2:45 AM
#
Avatar image of vcaretr
H/PC Newbie

Posts:
5
Status:
Hi everyone,

If I running an application, I want to know whether another application is running or not, how can I do this in the application programming.

thanks help
 Top of the page
chiark Page Icon Posted 2005-07-28 3:25 AM
#
Avatar image of chiark
H/PC Sensei

Posts:
1,330
Location:
North of England
Status:
Call "FindWindow" with the window class name.

The window class name can be found by using CESpy or something similar.

 Top of the page
vcaretr Page Icon Posted 2005-07-28 6:02 AM
#
Avatar image of vcaretr
H/PC Newbie

Posts:
5
Status:
I have use the FindWindow, But it retrieve the current application program.
The question is that I want to retrieve another application which some name "xxx.exe"
How can I achieve this??
 Top of the page
Snappy! Page Icon Posted 2005-07-28 8:32 AM
#
Avatar image of Snappy!
H/PC Elder

Posts:
1,712
Location:
New Mexico, US
Status:
vcaretr, I presume you know either the class name or window name of the main window of the app you are trying to find out if it is running.

static CWnd* PASCAL FindWindow(
LPCTSTR lpszClassName,
LPCTSTR lpszWindowName );

How is this app related to the app you are writing?
 Top of the page
chiark Page Icon Posted 2005-07-28 11:33 AM
#
Avatar image of chiark
H/PC Sensei

Posts:
1,330
Location:
North of England
Status:
Easiest way:
- Find the window class of the executable by using remote Spy++ from EVC++ tools
- search for that with findwindow

Harder way: get a list of processes running
- create a snapshot of the 32 processes running with CreateToolhelp32Snapshot
- Walk through the snapshot looking at the szExeFile in each PROCESSENTRY32 returned by calling Process32First then Process32Next
- Close the snapshot!

Option 1 is the way to go if you can do it.
 Top of the page
Jump to forum:
Seconds to generate: 0.187 - Cached queries : 62 - Executed queries : 9