I've noticed that nobody's posted a tutorial in the .NET section on how to receive command lines in a program. This is a relatively simple thing to do, and can yield great results. For those who don't know what command lines are, i'll explain.
When you execute a program, you add certain parameters called command lines. If anyone's ever worked with CMD using any command such as "ipconfing /release", "/release" is the command line, and tells the "ipconfig" executable what you want to do with it.
In this tutorial, we'll be using command lines in order to start a program minimized. Firstly, open Visual Studio 2010 (or Visual Basic 2010 depending on your installation), and create a new project.
Then, when the designer for Form1 is visible, double click form one, and go to the Form1_Load event. Add this code:
If Environment.GetCommandLineArgs.Count <> 1 Then If Environment.GetCommandLineArgs(1) = "/minimized" Then Me.WindowState = FormWindowState.Minimized End If End If
What the code above does is to check how many command lines have been sent to the program - if there's only one (which is the when launching any program), then we ignore it. Otherwise, we select the first Command Line that has been sent to the program and see if it is "/minimized". If so, we set the program's windowstate to minimized.
Now, to test this, create a new shortcut to your program. I've created an animated gif to show you how to do it:
Hopefully you guys will enjoy this tutorial and get something out of it. Please don't hesitate to ask me questions about it (although I'm not online every day anymore).
It should be very simple to adapt the code above to your needs - such as being able to open files with Command lines.
This post has been edited by Jack Eagles1: 30 January 2012 - 03:03 PM