How do I get the prog/path of a running app?

I want to monitor what programs are started on my computer by logging the program starts (using a callback?).  But, I can't find how I get the program name and path from a window or process handle.  How would I get this information?
chriskAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
ShrifConnect With a Mentor Commented:
You really should indicate which version of Windows you're talking about.GetModuleFileName takes a module or instance handle and returns the full pathname of the program.  Under Win32, this only works if the task calling the function create owns the module, such as the hInstance of the EXE, or a DLL that it has loaded.  Note: You can call GetWindowLong on an hWnd with GWL_HINSTANCE to obtain the hInstance that created the window.In Win32, the only portable way to do this is to go through the "performance registry".  Look at the source code to PerfMon, which comes with the Win32 SDK.  If your program is to be Windows 95 only, then you can use the the new ToolHelp 32 routines.  This is documented in the Windows 95 Device Drive Kit (DDK).  You'll have to ship the ToolHelp 32 DLL with your software.  ToolHelp 32 not available under Windows 95.The best way to do what you're doing is to write a DLL and then force that DLL to be loaded by all applications that are executed.  You can do this via the registry.  Every application that is executed will load your DLL.
0
 
chriskAuthor Commented:
Sorry, I am programming for Windows 95.

What do I update in the registry to cause my DLL to be loaded by all apps?  And when my DLL is loaded, how do I get the name and path of the program loading it?

I don't have the SDK as I am programming in Delphi and all it comes with is the Win32 help file.
0
 
ShrifCommented:
Look at "Getting the Filename Given a Window Handle".  You can just enter the "Q" number on Microsoft site's search: Q119163
0
 
chriskAuthor Commented:
I looked at the article you mentioned, but it only deals with NT.  I was looking for info on setting up a DLL to run when any app in Windows 95 is started.
0
All Courses

From novice to tech pro — start learning today.