Re: Adjusting a services "CanStop" on the fly?
From: Jay B. Harlow [MVP - Outlook] (Jay_Harlow_MVP_at_msn.com)
Date: 02/05/05
- Next message: Phil: "checked listbox to show new from"
- Previous message: Chrisg: "Re: Date/Time Data Type"
- In reply to: gregory_may: "Adjusting a services "CanStop" on the fly?"
- Next in thread: gregory_may: "Re: Adjusting a services "CanStop" on the fly?"
- Reply: gregory_may: "Re: Adjusting a services "CanStop" on the fly?"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 4 Feb 2005 23:18:20 -0600
Gregory,
> I was also unsuccessfull at navigating the windows station to deturmine
> who is trying to kill the service.
Which is what I stated in my other post, I really don't think you can
determine who is trying to kill the service. This would really be a Win32
question, you probably want to ask in a Win32 newsgroup!
> So, how can I enable/disable the ability for a user to kill my service
> (Via Task Manager) on the fly?
Again, as you found out, you can't change the setting on the fly, as it
doesn't really make sense to. What should the setting be when there is an
Admin logged in & a Non-Admin logged in? Don't forget other services can
control your service & each service is "logged in" to Windows...
I have not tried it, what happens if the OnStop method throws an exception?
Does the service still stop or will the stopping of the service be aborted?
I know if OnStart throws an exception the starting of the service is
aborted. I just don't know about the stopping. An exception may abort the
stopping of the service, keeping the service going, or it may simply keep
stopping the service... Of course you would still need to figure out who
actually made the request to decide if you should throw the exception...
It appears the RegisterServiceCtrlHandlerEx (a Win32 API) supports a
SERVICE_CONTROL_SESSIONCHANGE event, which notifies a service of session
change events. You could possibly use this event to be notified when the
"current user" changes from an Admin user & a non Admin user, unfortunately
ServiceBase hides the details of RegisterServiceCtrlHandler &
RegisterServiceCtrlHandlerEx from you... Again I would recommend you ask in
a Win32 newsgroup on the specifics of RegisterServiceCtrlHandler &
RegisterServiceCtrlHandlerEx...
Of course I may simply be miss reading what SERVICE_CONTROL_SESSIONCHANGE
really telling me...
Hope this helps
Jay
"gregory_may" <None> wrote in message
news:uXB22hvCFHA.2756@TK2MSFTNGP12.phx.gbl...
> According to this article, I cant change "CanStop" on the fly!!!
>
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemserviceprocessservicebaseclasscanstoptopic.asp
>
> So, how can I enable/disable the ability for a user to kill my service
> (Via Task Manager) on the fly?
>
> I would prefer not to tweak the regestry settings that permit Task manager
> from be available to a user. I have not had good luck down this path &
> task manager needs to be available for other reasons.
>
> I was hoping for a way to disable someone from killing my service if they
> dont have the Administrative Privledge.
>
> If I understand things correctly, the thread that a user will be running
> under is not known at the time the service starts. Users can log off/On
> with different privledges.
>
> I was also unsuccessfull at navigating the windows station to deturmine
> who is trying to kill the service. This article covers all the functions
> relating to figuring out who is logged in. With fast user switching under
> XP, several users can actually be logged into the PC at one time.
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/window_station_and_desktop_functions.asp
>
>
>
>
>
>
- Next message: Phil: "checked listbox to show new from"
- Previous message: Chrisg: "Re: Date/Time Data Type"
- In reply to: gregory_may: "Adjusting a services "CanStop" on the fly?"
- Next in thread: gregory_may: "Re: Adjusting a services "CanStop" on the fly?"
- Reply: gregory_may: "Re: Adjusting a services "CanStop" on the fly?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|