How to track the process starting "dllhost.exe"?

updated

I have a problem related to Process.Start(); My program runs files as processes, for example:

 Process processMonitor = new Process(); processMonitor.StartInfo.FileName = filePath; // Example: @"C:\test.txt" processMonitor.StartInfo.CreateNoWindow = true; processMonitor.Exited += new EventHandler(Process_Exited); processMonitor.EnableRaisingEvents = true; processMonitor.Start(); // Handle Exited event and display process information. private void Process_Exited(object sender, EventArgs e) { // This code is called on every exit, except images: (Windows Photo Viewer, *jpg, *png, *bmp etc.) } 

This successfully starts the notepad.exe process with the correct file. Capturing the Exit event also works so that basically I have everything to control the close event for the process.

Now for the problem ...

Doing the same thing, but now for the image:

 processMonitor.StartInfo.FileName = filePath; // Example: @"C:\test.jpg" 

This was unsuccessful .. The process starts fine, but I cannot determine if the process is closed. A little research shows me that the process is called

DLLHOST.EXE (COM Surrogate)

It starts and I cannot detect the Exited event for this process.

Can someone help me or at least point me in the right direction?

+4
source share
2 answers

If everything else does not work, you can look in WMI: http://msdn.microsoft.com/en-us/library/aa394582(v=vs.85).aspx - for this you need to perform some wrapping operation (or use wrapper, like here: http://www.codeproject.com/Articles/21971/WMI-Interface-for-NET )

Another option that you can use as a last resort, and as a workaround is to poll only for the state of the process, but this is really not recommended for most projects, and it certainly does not look like what you want to do in your project .

0
source

I think this is due to the nature of the image. Opening a .txt file starts notepad, while opening a .jpg opens a viewer. Any way to embed the viewer yourself?

0
source

Source: https://habr.com/ru/post/1489513/


All Articles