In my application, I have an option to start the application when Windows is started. That works great. I also have it so that, when minimized, the application is minimized to the system tray. Is there a way that I could have it be automatically minimized when started up at the same time as Windows? The only way I could think of, is to retrieve the amount of time that they system has been on and use that data to decide whether the machine had recently started. Obviously there are a lot of flaws with that theory. Anybody have any other ideas as to how this could be done?
+7
A:
Implement a command line switch in your program that causes your program to minimize to the tray. When you start the program with Windows startup, just include the switch.
Robert Harvey
2009-10-19 23:09:28
A lot of applications do this successfully. MSN Messenger uses a `/background` switch to achieve the same effect.
adrianbanks
2009-10-19 23:19:39
+1
A:
Use a command line argument, e.g. /startminimised. In your app check for the presence of this switch (using Environment.GetCommandLineArgs
) when the app starts, and automatically minimise if the switch is present.
Then in your "run on startup" option, ensure that the app is started with this switch e.g. set the Run registry key or Startup group shortcut to myapp.exe /startminimised
.
When the user runs your app, however, they won't (normally!) specify the switch, so the app will appear as a window.
itowlson
2009-10-19 23:10:35