开发者

Problem With WindowStyle and ProcessStartInfo

I am using this code right now:

ProcessStartInfo startInfo = new ProcessStartInfo();
Process process = new Process();

private void button1_Click(object sender, EventArgs e) {
    startInfo.FileName = @"D:\קוד C#\WindowsFormsApplication11\WindowsFormsApplication11\obj\x86\Debug\WindowsFormsApplication11.exe";
   // startInfo.Arguments = "-console -game cstrike +map de_dust +maxplayers 16 -port 27017";
    startInfo.WindowStyle = ProcessWindowStyle.Hidden;
    process.StartInfo = startInfo; 
    process.Start();
}

private void button2_Click(object sender, EventArgs e) {
    startInfo.WindowStyle = ProcessWindowStyle.Maximized;
}

The code is actually working very well, but the problem is:

When I start开发者_Go百科 the program (by clicking button1) the program runs as "hidden" (as I want). But how can I change it to not be in hidden mode?

Another question:

What about if the program can't get into hidden mode? What can I do then?


The normal way of doing this is by putting a system tray icon in. Once your program is hidden you make the system tray icon available, and put the action for showing the window again in a context menu on the tray icon.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜