gpt4 book ai didi

.net - 为什么StartInfo(ProcessStartInfo)总是空的?

转载 作者:行者123 更新时间:2023-12-04 11:18:09 24 4
gpt4 key购买 nike

根据 MSDN :

如果您没有使用 开始 启动进程的方法,开始信息 属性不反射(reflect)用于启动进程的参数。例如,如果您使用 获取进程 要获取计算机上运行的一系列进程,开始信息 每个人的属性(property)进程不包含用于启动进程的原始文件名或参数。

好吧,这完全有道理。我的问题是为什么即使您使用 Process.Start() 这些参数也是空白的?

例如:

    Dim startInfo As New ProcessStartInfo("firefox.exe")
startInfo.Arguments = "www.stackoverflow.com"
startInfo.WindowStyle = ProcessWindowStyle.Minimized
Process.Start(startInfo)
For Each proc As Process In Process.GetProcessesByName("firefox")
Debug.Print(String.Format("ProcessID={0}; Arguments={1}", _
proc.Id, proc.StartInfo.Arguments))
Next proc

在这种情况下,即使我提供了参数,该属性仍然是空的:

alt text http://www.sg-squared.com/images/startinfo.png

是什么赋予了?

最佳答案

您正在从 GetProcessesByName 返回一个不同的 Process 实例,它属于 MSDN 上语句的后一种情况。

关于.net - 为什么StartInfo(ProcessStartInfo)总是空的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/344056/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com