5

I am developing a Forms application that is either supposed to start on Windows boot (by registering a key in the registry) or by the actual user.

In case the user starts it by hand (i.e. clicking the executable file), I want the form to show up. In case Windows triggered the event, I want the application to be hidden (into the tray bar).

Is there a way to programmatically determine which of those cases occured?

Paolo Moretti
  • 54,162
  • 23
  • 101
  • 92
fjdumont
  • 1,517
  • 1
  • 9
  • 22

3 Answers3

7

I would suggest adding a command line parameter, something like -minimized and pass that when starting it on boot.

See this thread if you are looking for how to read the arguments.

Community
  • 1
  • 1
emartel
  • 7,712
  • 1
  • 30
  • 58
3

You can start you application upon Windows startup with a certain parameter, while a user will start it without this parameter.

Flot2011
  • 4,601
  • 3
  • 44
  • 61
1

The easiest way to do that, that I can think about, is:

When you register to run in Windows boot, pass a parameter (some default parameter), in case when user will run it, parameter will be absent.

In this way you would be able, depending on presence or absence of a paremeter, to determine the startup option of your program.

Tigran
  • 61,654
  • 8
  • 86
  • 123