开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜