我注意到,如果CreateNoWindow = FALSE確實當文件名指向一個Windows可執行文件,如果你有機會到winform應用程序的源代碼,絕對沒有,那麼你或許可以提供一個命令
static void Main(string[] args)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Form1 form1 = new Form1();
form1.Load += new EventHandler((s,o) =>
{
//check if the form should be shown based on command line arg
if (args.Contains("dontShowWindow"))
{
//hide it
form1.ShowInTaskbar = false;
form1.Visible = form1.ShowInTaskbar = false;
}
}
);
Application.Run(form1);
}
在你調用代碼,您現在可以指定「dontShowWindow」作爲一個過程參數:
控制形式的默認知名度,做這樣的事情在winform應用程序的啓動代碼行參數
ProcessStartInfo info = new ProcessStartInfo
{
CreateNoWindow = false,
WindowStyle = ProcessWindowStyle.Hidden,
UseShellExecute = false,
FileName = @"C:\temp\testWinForm.exe",
Arguments = "dontShowWindow"
};
Process.Start(info);
希望這有助於
可能會幫助告訴我們您嘗試運行的過程。 – Noldorin 2009-07-12 01:19:11
什麼,什麼都不開始或窗口顯示?如果沒有開始,那是因爲你忘了process.Start()... – 2009-07-12 01:20:52
是的,你有一個process.Start()調用是否屬於這個?我沒有看到你分配進程和命令行參數的地方。 – jjxtra 2009-07-12 01:23:16