Handle Operating System Events

Problem

You want your code to react to a Windows system event, such as a modification of system or desktop settings.

Solution

Add an event handler to one of the shared events provided by the Microsoft.Win32.SystemEvents class.

Discussion

The SystemEvents class provides references to several global system events, including:

  • DisplaySettingsChanged. occurs when the display settings (for example, screen resolution) are changed.

  • InstalledFontsChanged. occurs when the user adds fonts to or removes fonts from the system.

  • LowMemory. occurs if the system is running out of available RAM.

  • PaletteChanged. occurs when the user switches to an application that uses a different 256-color palette. This event occurs only in 256- color mode. ...

Get Microsoft® Visual Basic® .NET Programmer's Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.