Re: Does not receive events from Microsoft.Win32.SystemEvents when running as a Service.
- From: "Willy Denoyette [MVP]" <willy.denoyette@xxxxxxxxxx>
- Date: Sat, 4 Jun 2005 21:38:36 +0200
"esafran" <eyal@xxxxxxxxxxx> wrote in message
news:1117784088.916645.224580@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> Hi,
>
> I've have encountered a very strange behaviour under C#.
> My application is registering for:
> Microsoft.Win32.SystemEvents.DisplaySettingsChanged &
> Microsoft.Win32.SystemEvents.UserPreferenceChanged
>
> When I run my application as a Console Application (not as a service),
> my application receives the events when I change the screen resolution
> or change from Dual View to Horizontal Span or to Single View.
>
> However, when I launch my application as a service, it does not receive
> these events...
>
> I clicked on the "Interact with desktop" in the service properties.
>
> Anyone has any idea why it acts the way it does?
> If it cannot be done that way? any idea how it can be done?
>
> Best Regards,
> Eyal Safran.
>
The service runs in the security context of the SYSTEM pseudo account not
the "interactive logon user" so these events do not apply (desktop and user
preferences are user owned). When your service runs in the context of the
"interactive logon user", then it runs in a non interactive
desktop/winstation and again the changes to the interactive (active) desktop
do not apply (and aren't posted either). There is very little you can do
about this, and is yet another reason why Windows Services shouldn't have a
UI or interact with the UI for any reason other than debugging.
Willy.
.
- Follow-Ups:
- References:
- Prev by Date: Printing Preferences and Printing Defaults properties of a printer
- Next by Date: Re: How to get private class members using reflection
- Previous by thread: Re: Does not receive events from Microsoft.Win32.SystemEvents when running as a Service.
- Next by thread: Re: Does not receive events from Microsoft.Win32.SystemEvents when running as a Service.
- Index(es):
Relevant Pages
|