Update to ServiceControl package

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Update to ServiceControl package

Bill Schwab-2
Hello all,

My ServiceControl package has long been able to create and delete services,
but I didn't have much luck getting it to make in-place changes to existing
services.  Note that you can fry your machine with this stuff, so please
don't try it if you don't know what you are doing.  Otherwise, install the
package from my D5 goodies, and file in the code below.

Have a good one,

Bill


!ServiceController methodsFor!

disableService
 "Disable the receiver's service.  Messenger is a good one to try;
otherwise, be
 careful!!"

  | prerequisteServiceNames |

 self assert:[
  AdvApiLibrary default
   changeService:self handle
   dwServiceType:SERVICE_NO_CHANGE
   dwStartType:SERVICE_DISABLED
   dwErrorControl:SERVICE_NO_CHANGE
   lpBinaryPathName:nil
   lpLoadOrderGroup:nil
   lpdwTagId:nil
   lpDependencies:prerequisteServiceNames
   lpServiceStartName:nil
   lpPassword:nil
   lpDisplayName:nil.
 ].
! !
!ServiceController categoriesFor: #disableService!public! !

!ServiceControlManager class methodsFor!

disableService:displayName
 "Disable the named service.  Be careful!!"

 "
  ServiceControlManager disableService:'Messenger'.
 "

 ( ServiceControlManager new openServiceName:displayName ) disableService.
! !
!ServiceControlManager class categoriesFor: #disableService:!public! !

--
Wilhelm K. Schwab, Ph.D.
[hidden email]


Reply | Threaded
Open this post in threaded view
|

Re: Update to ServiceControl package

Chris Uppal-3
Bill Schwab wrote:

> My ServiceControl package has long been able to create and delete
> services, but I didn't have much luck getting it to make in-place changes
> to existing services.

Thanks for that Bill.  As it happens that's something I'll be wanting in the
next few weeks, and had no idea how to approach.

    -- chris


Reply | Threaded
Open this post in threaded view
|

Re: Update to ServiceControl package

Bill Schwab-2
Chris,

> > My ServiceControl package has long been able to create and delete
> > services, but I didn't have much luck getting it to make in-place
changes
> > to existing services.
>
> Thanks for that Bill.  As it happens that's something I'll be wanting in
the
> next few weeks, and had no idea how to approach.

As you have no doubt detected, the package needs a little work, but we'll
both be better off if we fix it rather than having you start from scratch.
The deprecated methods in ServiceController would be a good place to start
looking.  My hunch is that comparing their external call arguments to those
in #disableService will be useful.

It might also help (at least for using the package later) to split the
deprecated methods, once fixed, into multiple methods that change logically
related aspects.  There should also (I think) be a way to wait for a service
to start/stop/restart.  The caveat there is that the wait must not be
allowed to clobber Dolphin, and I have no idea whether the library is thread
safe, nor do I recall whether there is an asynchronous wait.  Maybe we can
simply poll the status of the service?

Have a good one,

Bill

--
Wilhelm K. Schwab, Ph.D.
[hidden email]