3

When you create a shortcut in windows to an application, in its properties you can define under "Run:" the initial window state (Minimized / Maximized / Normal). C# applications do not, apparently, start up their forms according to this configuration out-of-the-box, so I figured I need to get this information somehow and write a code that does that programmatically on start up. I cannot find a way to get this information in my c# application. I have tried:

Process.GetCurrentProcess().StartInfo.WindowStyle

But for some reason this is always "Normal" regardless of the configuration in the file shortcut.

Does anyone have any idea how to come around this?

4

1 回答 1

1

刚刚做了一个快速测试,只有当您的主窗体设置为正常窗口状态时,它才能开箱即用。如果您选择最小化或最大化,它将覆盖快捷方式设置。

如果您的主表单设置为正常,您可以使用以下代码检测实际状态:

FormWindowState actualState = Application.OpenForms["Form1"].WindowState;
if (actualState != FormWindowState.Normal)
{
    //probably launched via shortcut overriding the state, handle.
}
于 2013-09-08T12:36:44.700 回答