Reputation: 2230
I have written a Winforms application that will function in two ways:
If no command line arguments are supplied, the main form of the application will show, and the user can interact with the application.
If a command line argument is supplied, the main form is not shown, and the application perfoms the operation defined by the command line argument and then shuts down.
I would also like to display the command line argument to the user in a MessageBox, if the application is run from the Visual Studio IDE and the command line arugment has been specified in the Properties\Debug page.
Upvotes: 0
Views: 240
Reputation: 8776
You could always use System.Diagnostics.Debugger.IsAttached
Upvotes: 3
Reputation: 138841
If you need to determine the "parent process" of a given process, here is a link on SO: How to get parent process in .NET in managed way
That being said, what I would do instead is split your program in two: one class library (a DLL, that will contain all the real meat of what your program does) and one EXE that references this class library. This way you can create a 3rd project as a VS Addin that will also reference this class library, but will implicitely be aware that it's running from VS.
Upvotes: 2