Search code examples
c#winformsprocessgethandle

Can anyone help me to get handle of process which is called by func Process.Start();?


For example, I wanna get handle from browser.

 private void button1_Click(object sender, EventArgs e)
        {
            Process.Start("https://google.com/");
            //How to get handle of this process?
            
        }

Solution

  • Process.Start() returns a Process object of the newly created process.

    In the example below, myProcess.Handle is going to be the handle of said process.

    var myProcess = Process.Start("notepad.exe");
    Console.WriteLine(myProcess.Handle);