The answer to your question is http://www.codeproject.com/KB/threads/ParentPID.aspx
In short, you create a snapshot of all the processes that work with lpfCreateToolhelp32Snapshot(), and then iterate through it to find your process (indicated GetCurrentProcessId()) using lpfProcess32First()/lpfProcess32Next(). Once you find your own process, the structure you get gives you the process ID of the parent process, the one that launched your application.
Once you get the parent PID, it is easy to get the exe file name and other attributes with EnumProcessModules()and GetModuleFileNameEx().
But you can probably just use the code from the link.
source
share