English 中文(简体)
how to reliable capture display setting changed
原标题:
static void Main() 
{         
    // Set the SystemEvents class to receive event notification when a user 
    // when display settings change.
    SystemEvents.DisplaySettingsChanged += new 
        EventHandler(SystemEvents_DisplaySettingsChanged);        

    // For demonstration purposes, this application sits idle waiting for events.
    Console.WriteLine("This application is waiting for system events.");
    Console.WriteLine("Press <Enter> to terminate this application.");
    Console.ReadLine();
}

 private void SystemEvents_DisplaySettingsChanged(object sender, EventArgs e)
        {
   Console.WriteLine("Display setting change .");

}

i have created a windows service.when i restart the system and login then change the display setting it will not work and event is not fire but the service is runing.

when i restart the service then i change the display setting then display setting event fire.

i think SystemEvents.DisplaySettingsChanged may depend on some service.

问题回答

The SystemEvents class uses the WTSSession APIs under the covers, which rely on the Terminal Services service (TermService). If your service messes with SystemEvents before that service is started, it will fail in interesting ways. If you make your service depend on TermService, the SystemEvents init should work by the time your service starts.





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签