fail to get procees name (vb.net)
i wan to create a program that can get the application name
i can start the program but cant get the program name<br/><br/>
a = Process.Start("calc").Handle<br/>
MsgBox(a)<br/>
MsgBox(Process.GetProcessById(a).ToSt<开发者_如何学编程/ br>ring)<br/>
<br/>
it show Process with an Id of 1796 is not running, but the program already opened
Handle
!=Id
, and ToString()
won't give you the process name:
Dim a = Process.Start("calc").Id
MsgBox(a)
MsgBox(Process.GetProcessById(a).ProcessName)
Displays a process ID in one message box, then "calc" in the next.
If you had Option Strict On, you'd have received a warning already about your mixup between Handle and Id, since Handle
returns an IntPtr
, but GetProcessById
expects an Integer
.
精彩评论