Hi,
I've have encountered a very strange behaviour under C#.
My application is registering for:
Microsoft.Win32 .SystemEvents.D isplaySettingsC hanged &
Microsoft.Win32 .SystemEvents.U serPreferenceCh anged
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. 9 3401
Please, Anyone know another way to get Display Settings Changed event
while running as a service?
Eyal.
"esafran" <ey**@mokedor.c om> wrote in message
news:11******** **************@ o13g2000cwo.goo glegroups.com.. . Hi,
I've have encountered a very strange behaviour under C#. My application is registering for: Microsoft.Win32 .SystemEvents.D isplaySettingsC hanged & Microsoft.Win32 .SystemEvents.U serPreferenceCh anged
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 "interactiv e logon user" so these events do not apply (desktop and user
preferences are user owned). When your service runs in the context of the
"interactiv e 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.
Wow, these are very bad news you are telling me...
That means that I have to sample the
System.Windows. Forms.Screen.Al lScreens for changes every now and
then...
Do you think perhaps I will be able to get events from DirectX?
Thanks,
Eyal.
"Eyal Safran" <ey**@mokedor.c om> wrote in message
news:11******** **************@ f14g2000cwb.goo glegroups.com.. . Wow, these are very bad news you are telling me...
That means that I have to sample the System.Windows. Forms.Screen.Al lScreens for changes every now and then...
Do you think perhaps I will be able to get events from DirectX?
Thanks, Eyal.
DirectX and Windows.Forms needs a UI, again, Services should not have a UI
and should not assume to run in an interactive logon user context.
Why do you need to catch these events in a windows service in the first
place?
Willy.
Willy Denoyette [MVP] wrote: Why do you need to catch these events in a windows service in the first place?
My service as I mentioned in my first post, has the interact with
desktop checkbox, checked.
It does manipulation of graphics, and for that I need to know if the
resolution was changed or the monitors mode was switched to DualView of
SingleView or Horizontal Span.
It runs in the background.
Eyal.
"Eyal Safran" <ey**@mokedor.c om> wrote in message
news:11******** **************@ g14g2000cwa.goo glegroups.com.. .
Willy Denoyette [MVP] wrote:
Why do you need to catch these events in a windows service in the first place?
My service as I mentioned in my first post, has the interact with desktop checkbox, checked. It does manipulation of graphics, and for that I need to know if the resolution was changed or the monitors mode was switched to DualView of SingleView or Horizontal Span.
It runs in the background.
Eyal.
Well, that doesn't explain why it's implemented as a service, IMO it should
not.
Not sure what you mean with - It runs in the background, if it has a UI it
runs in the foreground and it makes no sense to run if there is no active
desktop (no interactive user logon).
Willy.
Willy Denoyette [MVP] wrote: Not sure what you mean with - It runs in the background, if it has a UI it runs in the foreground and it makes no sense to run if there is no active desktop (no interactive user logon).
It doesn't have a UI....
It interacts with the desktop image and thats why I need to know the
resolution...
Do you know any way I can query for resolution change?
Eyal.
"Eyal Safran" <ey**@mokedor.c om> wrote in message
news:11******** **************@ o13g2000cwo.goo glegroups.com.. .
Willy Denoyette [MVP] wrote:
Not sure what you mean with - It runs in the background, if it has a UI it runs in the foreground and it makes no sense to run if there is no active desktop (no interactive user logon).
It doesn't have a UI.... It interacts with the desktop image and thats why I need to know the resolution...
Do you know any way I can query for resolution change?
Eyal.
Having a UI means: human input (mouse, Keyboard etc...) and/or graphical
output to a display device. You said "it manipulates graphics" isn't that
(part of) a UI?
As I said before, Services are designed to run in the background without the
need for an active desktop or an interactive Logon session. What you need is
BOTH (Interactive Logon AND an Active Desktop) for the events to be
successfully delivered to the applications message queue, however, Windows
Services can't have both.
So please, answer the question - why does it have to be a Windows Service?
Willy.
Willy Denoyette [MVP] wrote: "Eyal Safran" <ey**@mokedor.c om> wrote in message news:11******** **************@ o13g2000cwo.goo glegroups.com.. .
Willy Denoyette [MVP] wrote:
Not sure what you mean with - It runs in the background, if it has a UI it runs in the foreground and it makes no sense to run if there is no active desktop (no interactive user logon).
It doesn't have a UI.... It interacts with the desktop image and thats why I need to know the resolution...
Do you know any way I can query for resolution change?
Eyal.
Having a UI means: human input (mouse, Keyboard etc...) and/or graphical output to a display device. You said "it manipulates graphics" isn't that (part of) a UI? As I said before, Services are designed to run in the background without the need for an active desktop or an interactive Logon session. What you need is BOTH (Interactive Logon AND an Active Desktop) for the events to be successfully delivered to the applications message queue, however, Windows Services can't have both. So please, answer the question - why does it have to be a Windows Service?
Willy.
Just so you would know... I solved the problem.
It appears that System.Windows. Forms.Screen hold an array of screens.
It is first initialized when using the propety Screen.AllScree ns.
Next time the property is addressed, it returns the same array.
The only time it receives a null value is when the
DisplaySettings Changed event occurs.
and guess what, it doesn't occur under a service...
So I created my own System.Windows. Form.Screen class (copy paste from
Lutz reflector).
which enumerates the screens every time I address the
MyScreen.AllScr eens property.
So every few minutes I get the updated Screen array...
Works for me...
Cheers,
Eyal. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Martijn Remmen |
last post by:
I have developed a service which exposes a COM object. This service is
running perfect on Windows 2000 Server and Windows 2000 Professional
under the SYSTEM account.
When the service is installed on Windows 2003 Server, the application
works well, and the COM object can be called just as it's meant to be.
The service is however running under the IWAM account (I know strange
account to run a service).
However, after a while (from...
|
by: Matt |
last post by:
When I try to run the ASP.NET application, it has the following error
messages:
Error while trying to run project: unable to start debugging on the web
server. The project
is not configured to be debugged
|
by: \Rob\ |
last post by:
On a domain controller, the ASPNET (v1.1) worker process (aspnet.wp.exe)
runs under the IWAM_machinename acount (IIS 5). I have expressly denied this
user the logon locally right in the domain controller GPO and yet this
profile gets created under the Document and Settings folder. The
IWAM_machinename registry hive remains loaded when the process ends. I have
to manually unload it with regedt32.exe. Is this normal behavior?
|
by: iclinux |
last post by:
Environment:
WinXP SP2 + Python 2.4.2, with SOAPpy-0.11.6.zip, fpconst-0.7.2.zip,
and PyXML-0.8.4.win32-py2.4.exe installed.
Problem:
I'm reading DiveIntoPython these days. When running code of "Example
12.11. Calling A Web Service Through A WSDL Proxy", I got some errors
as follow. Will you please give me some suggestion?
IDLE 1.1.2's Output:
|
by: Mike |
last post by:
Can a vb program running as a serice not use network paths to do file/io?
I can't seem to get my program to work with network paths and files. When I
use local disk it works fine. When I run it as a none service program it
works fine. I'm assuming that vb programs running as a service do not
support network paths. Is that true?
Thanks in advance.
| |
by: =?Utf-8?B?cnZhbmdlbGRyb3A=?= |
last post by:
Hello,
I have a problem with our OnlineBackupService.exe. This is a Windows Service
which is built in .Net 1.1 and basically grabs files from the file system and
will try to upload them using WebServices.
The service is installed by default using LocalSystem account. The exact
problem is that sometimes this service is not allowed to resolve the target
webservice. This results in the following exception:
|
by: =?Utf-8?B?S2F1c2hhbCBNZWh0YQ==?= |
last post by:
Hi,
Could you let me know what exactly happens when web service provider
receives request from the client (from system perspective, like threading and
all) ?
Also, how does the web service store the callback address of the web service
client so that asynchrony can be acheived (from system perspective) ?
Also, can we have message pattern where in client sends the callback address
|
by: Ben white |
last post by:
I did this before but can't remember how - please help. This is the
context:
1) .NET 1.1
2) Main form has a Task List Box, Go button, Cancel Button, Errors
List Box
3) Task list may have 1 to n tasks described
4) Tasks may be long running
5) When task launches it shows a "progress form" and closes it when
the task is complete
6) There is a Job object that performs the task.
|
by: Mario Suau |
last post by:
I'm working on a C# server based application using Sql Compact 3.5 as the database. It's designed to run as a service. My problem is that when I run the service, the following line of code takes 15 seconds to execute:
_dbConnection = new SqlCeConnection();
_dbConnection is declared as a SqlCeConnection inside of the class.
I'm positive that this line is what's causing the delay because I've commented out all of the other code so that...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |