• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

dapplo / Dapplo.Windows / 22325004088

23 Feb 2026 09:11PM UTC coverage: 32.847% (-0.2%) from 33.028%
22325004088

push

github

Lakritzator
Merge branch 'master' of https://github.com/dapplo/Dapplo.Windows

619 of 2002 branches covered (30.92%)

Branch coverage included in aggregate %.

1702 of 5064 relevant lines covered (33.61%)

29.45 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/Dapplo.Windows/Desktop/EnvironmentMonitor.cs
1
// Copyright (c) Dapplo and contributors. All rights reserved.
2
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3

4
#if !NETSTANDARD2_0
5
using System;
6
using System.Reactive.Linq;
7
using System.Runtime.InteropServices;
8
using Dapplo.Windows.User32.Enums;
9
using Dapplo.Windows.Messages.Enumerations;
10
using Dapplo.Windows.Messages;
11

12
namespace Dapplo.Windows.Desktop
13
{
14
    /// <summary>
15
    ///     A monitor for environment changes
16
    /// </summary>
17
    public class EnvironmentMonitor
18
    {
19
        /// <summary>
20
        ///     The singleton of the KeyboardHook
21
        /// </summary>
22
        private static readonly Lazy<EnvironmentMonitor> Singleton = new(() => new EnvironmentMonitor());
×
23

24
        /// <summary>
25
        ///     Used to store the observable
26
        /// </summary>
27
        private readonly IObservable<EnvironmentChangedEventArgs> _environmentObservable;
28

29
        /// <summary>
30
        ///     Private constructor to create the observable
31
        /// </summary>
32
        private EnvironmentMonitor()
×
33
        {
34
            _environmentObservable = SharedMessageWindow.Messages
×
35
                .Where(m => m.Msg == WindowsMessages.WM_SETTINGCHANGE)
×
36
                .Select(m =>
×
37
                {
×
38
                    var action = (SystemParametersInfoActions)(int)m.WParam;
×
39
                    var area = Marshal.PtrToStringAuto((IntPtr)m.LParam);
×
40
                    return EnvironmentChangedEventArgs.Create(action, area);
×
41
                })
×
42
                .Publish()
×
43
                .RefCount();
×
44
        }
×
45

46

47
        /// <summary>
48
        ///     The actual clipboard hook observable
49
        /// </summary>
50
        public static IObservable<EnvironmentChangedEventArgs> EnvironmentUpdateEvents => Singleton.Value._environmentObservable;
×
51
    }
52
}
53
#endif
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc