.NET Framework Bookmark and Share   
 index > .NET Base Class Library > How to Get Process Id of a running application?
 

How to Get Process Id of a running application?

Hi,

I am running a dotnet application.

In my application i want to get the processid simply.

How should i get it?

Thanks in advance

Amritha Chand
Hello,

Hope this code will help you
Pass process name in to the below function.It will return the id of the process.

Private Function GetProcessID(ByVal strProcessName As String) As Integer
Dim pID As Integer
Dim arrProcess As Process()
Dim p As System.Diagnostics.Process
arrProcess = Process.GetProcessesByName(strProcessName)

p = arrProcess.GetValue(0)
pID = p.Id
arrProcess = Nothing
p = Nothing
Return pID
End Function



AneeshSalim
Hello,

Hope this code will help you
Pass process name in to the below function.It will return the id of the process.

Private Function GetProcessID(ByVal strProcessName As String) As Integer
Dim pID As Integer
Dim arrProcess As Process()
Dim p As System.Diagnostics.Process
arrProcess = Process.GetProcessesByName(strProcessName)

p = arrProcess.GetValue(0)
pID = p.Id
arrProcess = Nothing
p = Nothing
Return pID
End Function



AneeshSalim
Thanks Aneesh
Amritha Chand

You can use google to search for other answers

Custom Search

More Threads

• Cannot assign PowerStatus to int
• .net 2.0 SP1 Change log - Where can I found it ?
• How to search for a file using wild cards
• How do i verify that server and client have same encryption key?
• Hidden Field _ViewState added to page even when enableviewstate=false
• Active Directory & ASP.NET 2 Integration
• How to get rid of the localization dll and have all the localization data emmbeded into the final assembly executable.
• .NET Security Permissions
• C#: Signing an assembly with a strong name using attribute
• How can I control my keyboard in C#?