jorge Posted March 6, 2004 Posted March 6, 2004 Hi, i have a plication with a few forms, but i'd like to add suport to start a part of it as a service, is that pasible without creating a new exe? like start with my.exe -service it will laod as service, start notmal it wil load in gui mode? Quote Jorge - http://www.blackdot.be/?page=apache.htm
AlexCode Posted March 7, 2004 Posted March 7, 2004 (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 March 7, 2004 by AlexCode Quote Software bugs are impossible to detect by anybody except the end user.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.