System.Diagnostics.Process.GetCurrentProcess().Id;

References
MSDN (GetCurrentProcessID), http://msdn.microsoft.com/en-us/library/ms683180(v=vs.85).aspx
MSDN (GetCurrentProcess), http://msdn.microsoft.com/en-us/library/system.diagnostics.process.getcurrentprocess.aspx

Ronnie Diaz Avatar

Published by

2 responses to “Get Current Process ID in C# .Net”

  1. vasa Avatar
    vasa

    don`t work, beach

    1. Ronnie Diaz Avatar

      Of course it works. Are you using Visual Studio C#.Net? In addition to GetCurrentProcess() you also have GetProcessById(), GetProcesses() and GetProcessesByName(). All of these are very useful functions for process management and are documented on Microsoft MSDN.

Leave a reply to Ronnie Diaz Cancel reply