Solved

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

Posted on 1997-06-09
4
271 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Suggested Solutions

This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
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…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

732 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