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

  • Thread starter SBh. via DotNetMonster.com
  • Start date
S

SBh. via DotNetMonster.com

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
 
L

learner

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
 
C

Chris Petchey

learner said:
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 said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top