I would like to get the path to the executable of the active foreground window.
I already have a foreground window handler:
[DllImport("user32.dll")]
static extern IntPtr GetForegroundWindow();
IntPtr handlerAppActual = GetForegroundWindow();
And I would like to get the path to its executable, for example, a shortcut. (for example: C: \ application \ application.exe)
Why do I need it? To use it later to automatically run the application with a call to its process, for example:
Process process = new Process();
process.StartInfo.FileName = @parametros[0];
process.Start();
Where "parametros [0]" is the path to the file.
I ask you to indicate the path to the application of the foreground window, but if you know any other way to do what I need (get the main foreground process for its implementation later), I would be glad to listen to it.
Thanks and welcome !!!