Click here to Skip to main content
12,554,005 members (62,048 online)
Rate this:
Please Sign up or sign in to vote.
See more: C# VB
Hello My Dear Friends

I have created an application in C# visual basic 2008, which is starting when System Starts then i am asking for a condition if it is false application get close ..but i want to start my application with an icon on desktop so that user can change the condition required to run application without get closed ........ it means i want to know when user start my application with icon on desktop or start menu.

please Help me ...
Posted 18-Nov-12 4:34am
Updated 18-Nov-12 4:48am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Easiest way is give it a parameter, or argument.
If you check in your Main Method (console type apps), or use Environment.GetCommandLineArgs() for winforms, you can read the parameters passed to the application.

Set up the System Startup version to have an parameter such as "/Automatic" or similar, and you can detect the startup mode pretty easily.
Syed Ghulam Ali 18-Nov-12 11:04am
thankyou for helping me Dear but can u give me a hint code to implement in windows application
OriginalGriff 18-Nov-12 11:16am
Look at the MSDN description of Environment.GetCommandLineArgs:
It gives an example.
Syed Ghulam Ali 19-Nov-12 5:17am
Thanks Dear for helping me ...........
OriginalGriff 19-Nov-12 5:26am
You're welcome!
Espen Harlinn 19-Nov-12 19:17pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

You can use my easy-to-use command line parsing library: Enumeration-based Command Line Utility[^].

It is complete with full source code and detailed explanation. Two previous articles explaining the techniques are referenced, as well as one alternative (more complex) command line utility.

Syed Ghulam Ali 19-Nov-12 5:19am
Thanks Dear for helping me i Got it......and sory for not using ur library but its very effective and even though i had lear a lot from it...
Sergey Alexandrovich Kryukov 19-Nov-12 11:38am
Not too late, but you can simply learn basic ideas...
You are welcome. Are you going to accept the answer formally (green button)? -- thanks.
Espen Harlinn 19-Nov-12 19:18pm
Well replied :-D
Sergey Alexandrovich Kryukov 19-Nov-12 19:29pm
Thank you, Espen.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.161021.1 | Last Updated 18 Nov 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100