我将WPF应用程序中的一些参数传递给这样的WinForm应用程序。
int processID = Process.GetCurrentProcess().Id;
Process p = new Process();
p.StartInfo.FileName = FileManager.AppDirectoryName + "\\" + winformApp;
p.StartInfo.Arguments = string.Format("Param1={0}", processID );
p.Start();
但在其他应用程序中,我看不到任何参数。
[STAThread]
static void Main()
{
// Get start arguments
var process = Process.GetCurrentProcess();
var args = process.StartInfo.Arguments; // It is empty. Why is it??
有任何线索吗?
答案 0 :(得分:3)
Process.GetCurrentProcess()
返回
与运行调用应用程序的进程资源关联的新Process组件。
这个新组件将有一个空的startinfo成员。只需使用
Environment.GetCommandLineArgs()
相反。