Hi Pierre,
In a VB .NET Windows application, Form1 is specified as the startup object by default; however, a form-level Main method is not exposed in the source code. Behind the scenes, the Visual Basic .NET compiler inserts a Main method into the IL code to satisfy .NET’s requirement that all programs must have a Main method. This model was chosen to help simplify VB .NET Windows Forms applications. If you don’t want a form to be the first object instantiated in your VB .NET application or you need to pass parameters, you can create a new module and add a Main method to it. For example:
Module MyFirstVBNetProgram
Function Main(ByVal CmdArgs() As String) As Integer
If CmdArgs.Length > 0 Then
Dim Parms, Parameter As String
For Each Parameter In CmdArgs
Parms += Parameter & " "
Next
MessageBox.Show(Parms)
End If
Return 0
End Function
End Module
Then right-click on the Project and go into Properties. Change the Startup Object to the name of the Module (for the sample above: MyFirstVBNetProgram).
>Hi !
>
>Used to do it in Fox, but in VB Net...
>
>How do pass parameters to an application (exe), so that on startup I can detect if the exe was launched from my main app.
>
>The main purpose is to prevent running this application without first Login into the main app.
>
>TIA
>
>Pierre
-----------------------------------------
Cathi Gero, CPA
Prenia Software & Consulting Services
Microsoft C# / .NET MVP
Mere Mortals for .NET MVP
cgero@prenia.comwww.prenia.comWeblog: blogs.prenia.com/cathi