Get Current Process ID in C# .Net
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
Posted on May 3, 2011, in Programming & Development and tagged .net, api, c#, get process id, getcurrentprocess, interop, process, system.diagnostics.process, win32, win32 api. Bookmark the permalink. 2 Comments.
don`t work, beach
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.