为什么StartInfo的(的ProcessStartInfo)总是空的? [英] Why is StartInfo (ProcessStartInfo) always empty?

查看:135
本文介绍了为什么StartInfo的(的ProcessStartInfo)总是空的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据一>:

According to MSDN:

如果您没有使用开始方法来启动一个进程,在的StartInfo 属性不反映用于启动该流程的参数。例如,如果你使用 GetProcesses 以获得在计算机上运行的进程的数组,在的StartInfo 每个工艺性能不包含原始文件名或参数来启动进程。

If you did not use the Start method to start a process, the StartInfo property does not reflect the parameters used to start the process. For example, if you use GetProcesses to get an array of processes running on the computer, the StartInfo property of each Process does not contain the original file name or arguments used to start the process.

好吧,这是非常合情合理的。我的问题是为什么这些参数为空,即使你使用的Process.Start()?

Okay, that makes perfect sense. My question is why are these parameters blank even when you do use 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

在,即使我提供的参数这种情况下,房地产仍然是空的:

In this case even though I provided Arguments, that property is still empty:

怎么办?

推荐答案

您还在做一个GetProcess,因此它会继续工作相同。你开始不会有所作为的事实。

You are still doing a GetProcess, thus it continues to work the same. The fact that you started it doesn't make a difference.

的Process.Start(...)返回启动的进程。我希望,如果你检查的StartInfo的属性,它会被填充。

Process.Start(...) returns the process that you started. I expect that if you check the StartInfo property on that, it will be populated.

这篇关于为什么StartInfo的(的ProcessStartInfo)总是空的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆