English 中文(简体)
C# - 尽量减少在系统启动时的射线
原标题:C# - Minimize to tray at system startup
  • 时间:2009-10-19 23:00:49
  •  标签:

在我的申请中,我可以选择在Windows开始时开始申请。 这发挥了巨大作用。 我也这样认为,在尽量减少这一应用时,该应用程序将降至最低。 在与Windows同时启动时,我是否可以自动地将其减少到最低限度? 我认为,唯一的办法是收回其系统投入的时间,并利用这些数据来决定机器最近是否已经启动。 显然,这一理论存在许多缺陷。 没有人对如何做到这一点有什么其他想法?

最佳回答

在你的方案中实施一条指挥线,使你的方案减少到最低限度。 当你开始视窗启动方案时,仅包括开关。

问题回答

在“收益”表中,“收益”改为“收益”。

     //After this:
     InitializeComponent();
     //Place this line:
     WindowState = FormWindowState.Minimized;

希望这一帮助!

使用指挥线论点,例如/启动。 在您的问答中(使用Environment.GetCommandLineArgs)这一开关时,如果开关,自动减小。

然后,在您的“启动”选择中,确保从这一交换开始,例如将开放式登记处的关键或启动小组定在<条码>上。

然而,当用户使用你的包料时,他们打上了打字机(通常!)具体说明开关,因此,照相机将成为窗户。

您可以把方案称为“管理”等参数,然后在你的方案中处理这一参数:

在你的方案中,处理参数,然后将这一参数变为表1:

        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            if (args.Length != 0){
                Application.Run(new Form1(args[0]));
            }
            else
            {
                Application.Run(new Form1("normalState"));
            }
        }

在表格1.c中,你可以称职,其参数为:

    public Form1(string parameter)
    {
        InitializeComponent();
        SetStartup(); //This function will set your app in the registry to run on startup. I ll explain this function below.
        MinimizeApp(parameter);
    }

例如,在使用这一功能时,如果你开始使用公用公用公用公用公用公用公用公用公用公用公用公用公用公用公用公用公用公用公用公用公用公用公域,则会开始尽量减少这种应用,通知员会pop忙,并说电灯已经启动,并在背景中运行。

public void MinimizeApp(string parameter)
{
    if (parameter == "-minimized")
    {
        this.WindowState = FormWindowState.Minimized;
        notifyIcon1.Visible = true;
        notifyIcon1.BalloonTipText = "Program is started and running in the background...";
        notifyIcon1.ShowBalloonTip(500);
        Hide();
    }

}

《原则和规则》职能将你的方案纳入登记册,因此其启动时间。

private void SetStartup(){
    Microsoft.Win32.RegistryKey key;
    key = Microsoft.Win32.Registry.CurrentUser.CreateSubKey(@"SOFTWAREMicrosoftWindowsCurrentVersionRun");
    key.SetValue(AppName, Application.ExecutablePath.ToString());
    string ApplicationPath = """ + Application.ExecutablePath.ToString() + "" -minimized";
    key.SetValue("MyApplicationName", ApplicationPath);
    key.Close();
}

现在,当你开始使用公用公用公用公用公用公用公用公用公用公用公用公用公用公用公用公费,即“c:/programs/app.exe”——时,会开始尽量减少,当你重新启用你的电脑时,也开始自动降低。





相关问题
热门标签