C# Run application MINIMIZED at windows startup

后端 未结 5 1938
盖世英雄少女心
盖世英雄少女心 2020-12-10 08:59

I got the following code to run the application at windows startup:

    private void SetStartup(string AppName, bool enable)
    {
        string runKey = \"         


        
5条回答
  •  抹茶落季
    2020-12-10 09:50

    Had a really hard time finding a good answer to this, finally found it in a really old book. On my Forms application, just opened the program.cs and changed

    Application.Run(new Form1());
    

    to

    Form1 f = new Form1();
    f.WindowState = FormWindowState.Minimized;
    f.ShowInTaskbar = false;
    Application.Run(f);
    

    and it opens without a flicker directly to the tray. This app was more just a service, so set it to just have a notify icon and exit button when right clicked. Hope this helps!!

提交回复
热议问题