Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect whether application started from startup or started by user?

Tags:

c#

I'm making a windows forms application in c# that will start in windows start up . User also can start the application from its icon on desktop.I want the application to be minimized in system tray if it was started from windows start up and to be in normal windows state if started by user clicking on its shortcut icon. Is there a a way to detect whether the application started by user or by start up ?

EDIT

i am using this code to make application appear on startup

regesiterykey.SetValue("MyApp", Application.ExecutablePath.ToString());
like image 608
CSharpBeginner Avatar asked Dec 03 '22 05:12

CSharpBeginner


2 Answers

You can add a command line argument to the Startup shortcut, then check for that argument and minimize the program.

You can probably also set the shortcut to open minimized. (Depending on your GUI) (But not with the registry)

like image 81
SLaks Avatar answered Dec 17 '22 16:12

SLaks


Use instead this one:

regesiterykey.SetValue("MyApp /minimized", Application.ExecutablePath.ToString());
like image 38
Oliver Avatar answered Dec 17 '22 15:12

Oliver