Re: StartService with arguments



> From which Post?

This one, it's showing up here on two different machines (and two different
ISPs)

"Mike D Sutton" <EDais@xxxxxxxx> wrote in message
news:<e6YCPRnBGHA.2644@xxxxxxxxxxxxxxxxxxxx>...
> > I use the WinAPI-Method StartService() to Start a Service.
> >
> > This is from the MSDN:
> >
> > BOOL StartService(
> > SC_HANDLE hService,
> > DWORD dwNumServiceArgs,
> > LPCTSTR* lpServiceArgVectors
> > );
> >
> > This works with StartService(hService, 0, 0). Now, I would to use
> > Arguments.
> > Now, can anybody tell me, how does I have to use the Parameter
> > lpServiceArgVectors in VisualBasic6?
>
> This is untested, but try something like this:
>
> '***
> Private Declare Function StartService Lib "AdvAPI32.dll" Alias
> "StartServiceA" ( _
> ByVal hService As Long, ByVal dwNumServiceArgs As Long, ByVal
> lpServiceArgVectors As Long) As Long
>
> ...
>
> Dim Args() As String
>
> ' Fill Args[] here
>
> Call StartService(hService, UBound(Args) - LBound(Args) + 1, ByVal
> VarPtr(Args(LBound(Args))))
> '***
>
> If you need the Unicode version then try something like this:
>
> '***
> Private Declare Function StartService Lib "AdvAPI32.dll" Alias
> "StartServiceW" ( _
> ByVal hService As Long, ByVal dwNumServiceArgs As Long, ByVal
> lpServiceArgVectors As Long) As Long
>
> ...
>
> Dim Args() As String
> Dim WideArgs() As Long, LoopArgs As Long
>
> ' Fill Args[] here
>
> ReDim WideArgs(LBound(Args) To UBound(Args)) As Long
> For LoopArgs = LBound(Args) To Ubound(Args)
> WideArgs(LoopArgs) = StrPtr(Args(LoopArgs))
> Next LoopArgs
>
> Call StartService(hService, UBound(Args) - LBound(Args) + 1, ByVal
> VarPtr(WideArgs(LBound(Args))))
> '***
>
> Hope this helps,
>
> Mike
>
>
> - Microsoft Visual Basic MVP -
> E-Mail: EDais@xxxxxxxx
> WWW: Http://EDais.mvps.org/


.



Relevant Pages

  • Re: StartService with arguments
    ... What does I have to do to read back the parameters in the ServiceMain() ... >>> lpServiceArgVectors in VisualBasic6? ... >> Dim Args() As String ... LoopArgs As Long ...
    (microsoft.public.vb.winapi)
  • Re: StartService with arguments
    ... Declare Function StartService Lib "advapi32.dll" Alias ... ByVal hService As Long, ByVal dwNumServiceArgs As Long, ... ByVal lpServiceArgVectors As Long) As Integer ...
    (microsoft.public.vb.winapi)
  • Re: StartService with arguments
    ... I have to use the paramter lpServiceArgVectors? ... > ByVal hService As Long, ByVal dwNumServiceArgs As Long, ... >> I use the WinAPI-Method StartService() to Start a Service. ...
    (microsoft.public.vb.winapi)