I am trying to find a way to get a callback in C# when any new user process starts on the machine. For example, if I opened a Word document from Outlook, I'd like to get a callback and decipher that the Word document was opened by Outlook. Similarly, if I click a link in a Word document which opens a web browser, I'd like to know that web browser was opened by Word document.
I have investigated the parent process idea and in some cases, this works. For example, if I start Word from the taskbar I can decipher that Word was started by Explorer. If I open a PDF from Outlook, I can tell that Adobe Reader was started by Outlook. However, if I click on a link in an e-mail, a new process is created in Chrome to handle this (one process per tab), but all it tells me via getting the processes parent is that Chrome was started by Chrome.
There are also further problems that other browsers such as Mozilla Firefox and Internet Explorer (unless you don't alter the settings), don't have one process per tab. Instead they only have one in total. In this case, the best I could hope for would be to be able to access information relating to whatever opened the first tab when the process was first started.
I was wondering if anybody knew a way round this? My thinking is that the Operating System must do something when these events happen. For example, clicking a link in an e-mail must alert the OS to find the default web browser somehow? Similarly with clicking a PDF in Outlook, the OS must detect this and go and find the default program for PDFs.
If anyone has any ideas how I can find out this information in C# I would be very grateful.
Summary: I'd like a callback each time a new application window or tab is opened along with what application window/process asked for this program to be opened.
Many thanks in advance for your help.