tags:

views:

459

answers:

3

My application will be launched by an installer during the installation process, probably using ShellExecute. I would like to get the name of the installer executable when it launches my application.

Can I from my application see a "parent process" somehow? Or can I scan the system for windows with a specific caption and get the name of the .exe owning that window?

This is for MS Windows, and my application is written in C++.

A: 

I don't know how to do that, but I would pass caller name as a parameter to the exe such as --caller ParentName. That way you don't even care if it's windows.

Budric
+1  A: 

There is no way to get the "parent" process of a particular process. Windows doesn't have such a concept. Your second option is a possibility. Use FindWindow() to locate the window in question. Call GetWindowThreadProcessId() to get the process ID of the owning process. Call OpenProcess() to get a process handle. And finally, call GetModuleFileNameEx() to retrieve the name of the module.

Peter Ruderman
A: 

windows does have the concept of parent process.. i donno why would you just claim that ignorantly..

http://www.codeproject.com/KB/threads/ParentPID.aspx

Aesqw