Solved

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

Posted on 1997-06-09
4
267 Views
Last Modified: 2013-12-03
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?
0
Comment
Question by:chrisk
  • 2
  • 2
4 Comments
 

Accepted Solution

by:
Shrif earned 140 total points
ID: 1397969
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
 

Author Comment

by:chrisk
ID: 1397970
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
 

Expert Comment

by:Shrif
ID: 1397971
Look at "Getting the Filename Given a Window Handle".  You can just enter the "Q" number on Microsoft site's search: Q119163
0
 

Author Comment

by:chrisk
ID: 1397972
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

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question