0

I have the following scenario, I need to detect a particular program running in windows before I can execute my program, for example my program needs to know if LogMeIn is actually installed and running to proceed, I have used some approaches like enumerating processes using psapi.dll but I think that the process name could change in the installation and configuration stage, so I dont know how to make sure that I can find always the process independently of this. I am using some tests based upon the following code snippets: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682623(v=vs.85).aspx

The other approach is to use the registry code but I detect that it could be modified too and it is not standard.

willyMon
  • 612
  • 8
  • 19
  • `EnumProcesses` is the approach I would take too. I don't see what the problem is. If the program name changed, it's not really the same program anymore. There's not much you can do about that. An alternative is to check the file system/registry. Again, these could change too though. – Mike Kwan Mar 27 '12 at 16:06
  • By *process name* do you mean the name of the *.exe*, and not the application name? – hmjd Mar 27 '12 at 16:09
  • I use the name of the application itsef. and the idea is always detect that logMein and others are running not matter if the program is running with a changed name or a change registry key etc I am trying to identify the most standard approach to get the right PID associated and act accordingly then. – willyMon Mar 27 '12 at 16:21
  • I agree; identity is fuzzy. Is the Notepad.EXE from Windows 7 the same as that in Windows 3.11; if not then which versions _are_ equal ? Besides, your "use the registry approach" incorrectly assumes that a running program must have a registry entry. – MSalters Mar 27 '12 at 18:14
  • If the EXE is not found, then go ahead and raise a false negative "You must run LogMeIn before running this program". Maybe give them a "Proceed anyway" button. – Raymond Chen Mar 27 '12 at 20:38

1 Answers1

0

If the program you want to track is windowed (so a windows iss shown) and the window title is something you predict. You can use the EnumWindows function. If the title changes but still have some words that are the same accross the different run, you can use regular expression to see if the name match what you want. Example:

LogMeIn running...

2012-03-27: LogMeIn

Those two string share a common and explicit name, so you can tell that will be what your looking for. You can apply this reasonning to the EnumProcess method

Community
  • 1
  • 1
grifos
  • 3,321
  • 1
  • 16
  • 14
  • yes this could be useful when is windowed, so the next step is to get the approach to identify unwindowed programs. – willyMon Mar 27 '12 at 16:23
  • What are the info you know that can helps you to identify the program? The executable name? The installation path? A registry entry that give you the path? – grifos Mar 27 '12 at 16:58
  • In case you enumerated processes and the name of the executable your looking for vary, but you always know where it should be installed, you can use the GetModuleFileNameEx function to get the path (whith name) of the executable that started the process. – grifos Mar 27 '12 at 17:04