Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想创建一个可以获取应用程序名称的程序 我可以启动程序但无法获取程序名称
<br/><br/> a = Process.Start("calc").Handle<br/> MsgBox(a)<br/> MsgBox(Process.GetProcessById(a).ToSt</ br>ring)<br/> <br/>
它显示 ID 为 1796 的进程未运行,但程序已打开
Handle!= Id,并且ToString()不会给你进程名称:
Handle
Id
ToString()
Dim a = Process.Start("calc").Id MsgBox(a) MsgBox(Process.GetProcessById(a).ProcessName)
在一个消息框中显示进程 ID,然后在下一个消息框中显示“计算”。
如果您启用了 Option Strict On,那么您已经收到了关于您在 Handle 和 Id 之间混淆的警告,因为Handle返回一个IntPtr,但GetProcessById需要一个Integer.
IntPtr
GetProcessById
Integer