How can I call and pass parameter to Windows Service in VB.NET ?

Discussion in 'Microsoft VB .NET' started by SBh. via DotNetMonster.com, Oct 5, 2005.

  1. I already created a windows service that receive parameter in Sub GetValue ()
    and I can registered and started service successfully. But unfortunately, I
    don't know how to write program to call this windows service.

    Anyone can help me and give me some example code, please ....

    My windows service source code are as below :
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    Protected Overrides Sub OnStart(ByVal args() As String)
    GetValue (args(1), args(2))
    End Sub

    Public Shared Sub GetValue (ByVal Arg1 as String, ByVal Arg2 as String)
    .... [ Calculate and return result ] ...
    End Sub
     
    SBh. via DotNetMonster.com, Oct 5, 2005
    #1
    1. Advertisements

  2. SBh. via DotNetMonster.com

    learner Guest

    I am not quite sure how to handle this, but I think I have seen something
    in msdn about this. I vaguely remember it mentioned safearray.

    Hope you find the article under interop
    "SBh. via DotNetMonster.com" <u14583@uwe> wrote in message
    news:55622ecb70c46@uwe...
    >I already created a windows service that receive parameter in Sub GetValue
    >()
    > and I can registered and started service successfully. But unfortunately,
    > I
    > don't know how to write program to call this windows service.
    >
    > Anyone can help me and give me some example code, please ....
    >
    > My windows service source code are as below :
    > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    >
    > Protected Overrides Sub OnStart(ByVal args() As String)
    > GetValue (args(1), args(2))
    > End Sub
    >
    > Public Shared Sub GetValue (ByVal Arg1 as String, ByVal Arg2 as String)
    > .... [ Calculate and return result ] ...
    > End Sub
     
    learner, Oct 6, 2005
    #2
    1. Advertisements

  3. In message <>, learner
    <> writes
    >I am not quite sure how to handle this, but I think I have seen something
    >in msdn about this. I vaguely remember it mentioned safearray.
    >
    >Hope you find the article under interop
    >"SBh. via DotNetMonster.com" <u14583@uwe> wrote in message
    >news:55622ecb70c46@uwe...
    >>I already created a windows service that receive parameter in Sub GetValue
    >>()
    >> and I can registered and started service successfully. But unfortunately,
    >> I
    >> don't know how to write program to call this windows service.
    >>
    >> Anyone can help me and give me some example code, please ....
    >>
    >> My windows service source code are as below :
    >> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    >>
    >> Protected Overrides Sub OnStart(ByVal args() As String)
    >> GetValue (args(1), args(2))
    >> End Sub
    >>
    >> Public Shared Sub GetValue (ByVal Arg1 as String, ByVal Arg2 as String)
    >> .... [ Calculate and return result ] ...
    >> End Sub

    >
    >

    In your application:

    myController = New ServiceController("MyService")
    myController.ExecuteCommand(n)
    'where n is an integer in range 128-255



    This will appear as the arguement in the OnCustomCommand event of your
    service




    --
    Chris Petchey
     
    Chris Petchey, Oct 6, 2005
    #3
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Raj
    Replies:
    2
    Views:
    243
  2. Guest
    Replies:
    5
    Views:
    268
    Cor Ligthert
    May 24, 2004
  3. Guest
    Replies:
    0
    Views:
    368
    Guest
    Dec 13, 2005
  4. Luqman
    Replies:
    3
    Views:
    1,305
    Cor Ligthert [MVP]
    Mar 20, 2006
  5. vishruth
    Replies:
    1
    Views:
    1,225
    Michel Posseth [MCP]
    Jan 1, 2008
Loading...

Share This Page