Windows Secrets for Visual Basic, Part 1, Page 5
The Power of Command-Line Parameters
Command line parameters can be incredibly useful. They allow users or other applications to pass startup information to your program. For example, if your program was called myapp.exe, they might run the following:
Here, we have one command line parameter, "/nodialogs". In VB6, we could read this using the Command property. In VB.NET, this has been replaced with the System.Environment.GetCommandLineArgs function, which returns an array of the passed parameters.
Dim MyStartupArguments()As String, intCount As Integer MyStartupArguments = System.Environment.GetCommandLineArgs For intCount = 0 To UBound(MyStartupArguments) MessageBox.Show(MyStartupArguments(intCount).ToString) Next
Coming up in part two of Windows Secrets, learn how to:
- Extract HTML from the RichTextBox control
- Create applications that accept drag-and-drops from Windows Explorer
- Capture the screen, quick and easy
- Use the .NET equivalent of PrevInstance.
See you then!
About the Author
Karl Moore is a technology author living in Yorkshire, England. He runs his own consultancy group, White Cliff Computing Ltd, and is author of two best-selling books exposing the secrets behind Visual Basic .NET. When he's not writing for magazines, speaking at conferences, or making embarrassing mistakes on live radio, Karl enjoys a complete lack of a social life. You can visit Karl on the Web at www.karlmoore.com.
# # #
Page 5 of 5