Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (edited)

I came up with this code for you:

 

Imports System.Windows.Forms

Module Global
   Public frm1 As New Form1

   Sub Main(ByVal CmdArgs() As String)

       Try
           If CmdArgs.Length > 1 Then
               Console.WriteLine("Too many arguments!")
               Exit Sub
           End If

           MessageBox.Show(CmdArgs(0))
       Catch ex As Exception
           'If no parameters then lounch the form...
           Application.Run(frm1)

           'You can also lounch another existing exe like this
           'System.Diagnostics.Process.Start("c:\myapp.exe")
       End Try

   End Sub

End Module

Note that this is the Sub Main of a Console application project... NOT a Windows project!

Also note that instead of that messagebox I throw on the try you can call your Windows Service or whatever you like depending on the parameters you pass...

 

Alex :p

Edited by AlexCode
Software bugs are impossible to detect by anybody except the end user.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...