RUNNING PROGRAM DETECTION
> I need to write a program that will look for certain active programs (for
> example Launcher.exe) while they are in memory.
There are 2 ways to do this. Using FindWindow or EnumWindowsworks on all 32bit
windows versions, but is only suitable if the applicaiton has a main window and
the title doesn't change. The better method is Enumerating processes, this is
different between Win9x and WinNT.
I have examples of both methods at:
www.viewpointsa.com\faq\
Look for FAQ 3 & FAQ 4.
Regards,
Anthony Richardson
anthony@viewpointsa.com
*************************************************************
Andrew,
take a look at the delphi-programming files section (egroups.com) there is
a windowwalk.zip file which lists all running windows on the system. This
should get you started.
Other than that take a look at the following API's
FindWindow
GetWindow
GetTopWindow
GetParentWindow
EnumWindows
EnumChildwindows
Si Carter
Orcka Development (http://www.orcka.com)
~ Email: simon.carter@orcka.com
**************************************************************
> Finally, you will need to call
> CreateToolhelp32Snapshot to get a list of all of the active threads and
> check whether any of them match your window's thread. If so, you can check
> the member variables of the structure returned in Process32Next for the
> executable name.
It is important to note that ToolHelp32 only works under Win9x/ME, for WinNT/2K
you need to use PSAPI.DLL.
An example Delphi Object wrapper around both is availble on my site
(www.viewpointsa.com\faq\) look for FAQ 4 "How do I enumerate all processes
running on Windows?". This will use the correct method automatically making your
application WinOS neutral.
Regards,
Anthony Richardson
anthony@viewpointsa.com
*******************************************************************
Although you can find many examples by searching for EnumWindows and Delphi
in Google, You will probably have to do something like the following:
Each time that windows calls back your EnumWindowsProc function, it will
give you the handle of a window. If that window is a top level window, with
no owner, etc. then you will need to get the thread that owns that window
with GetWindowThreadProcessId. Finally, you will need to call
CreateToolhelp32Snapshot to get a list of all of the active threads and
check whether any of them match your window's thread. If so, you can check
the member variables of the structure returned in Process32Next for the
executable name.
This is the only way I know how to get the exe name of a window. Does
anyone else know a better way?