2
public partial class Form1 : Form
{
    [DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
    private static extern IntPtr GetForegroundWindow();

    public Form1()
    {
        InitializeComponent();
        var proc = Process.GetProcesses().Single(x => x.Handle == GetForegroundWindow());
    }
}

I've tried running the app as Administrator, no go. What am I doing wrong here that I get this exception?

Perry
  • 2,250
  • 2
  • 19
  • 24

1 Answers1

1

Turns out that the whole loop I was doing was also going over protected processes which resulted in access denied

Perry
  • 2,250
  • 2
  • 19
  • 24