Private Function GetPID(ByVal processName As string) As Int32
if processName.endswith(".exe") then
processName = processName.replace(".exe", "")
end if
Dim proc as new Process() = Process.GetProcessesByName(processName)
If proc.Length>0 then
GetPID = proc(0).Id
Else: GetPID = 0
End if
End Function
Usage:
GetPID("explorer.exe")
No comments:
Post a Comment