How to get active process name in C#?
I know that I must use this code:
[DllImport(\"user32.dll\")] private static extern IntPtr GetForegroundWindow(
I would suggest using System.Diagnostics.Process.
System.Diagnostics.Process
var currentProc = System.Diagnostics.Process.GetCurrentProcess(); string name = currentProc.ProcessName;
As an alternative you could use:
string name = currentProc.MainModule.FileName;