title: Get current active application name in Windows 10 using C#
body: <p>I tried get current active application name (or process name) but in some application like Microsoft Edge is result ApplicationFrameHost. Is there way to get application name such as in Task manager?</p>
  
  <p>My actual code:</p>
  
  <pre><code>    [DllImport("user32.dll")]
      static extern IntPtr GetForegroundWindow();
      [DllImport("user32.dll")]
      static extern int GetWindowText(IntPtr hWnd, StringBuilder text, int count);
      [DllImport("user32.dll")]
      public static extern IntPtr GetWindowThreadProcessId(IntPtr hWnd, out uint processId);
  
              private string GetActiveProcess()
      {
  
          const int nChars = 256;
          uint processId;
          StringBuilder Buff = new StringBuilder(nChars);
          IntPtr handle = GetForegroundWindow();
  
          if (GetWindowText(handle, Buff, nChars) &gt; 0)
          {
              GetWindowThreadProcessId(handle, out processId);
              return Process.GetProcessById((int)processId).ProcessName;
          }
          return null;
      }
  </code></pre>