Live Chat Icon For mobile
Live Chat Icon

How can I tell if the user has changed some system preference such as the locale or display settings

Platform: WinForms| Category: Tips

Use the static events in the SystemEvents class found in the Microsoft.Win32 namespace. There are many events in this class. Here are a couple:

	SystemEvents.DisplaySettingsChanged += new System.EventHandler(displaySettingsChanged);
	SystemEvents.UserPreferenceChanged += 
				new UserPreferenceChangedEventHandler(userPreferencesChanged);

	.............
	.............

	private void displaySettingsChanged(object sender, EventArgs e)
	{
		MessageBox.Show(e.ToString());
	}
	
	private void userPreferencesChanged(object sender, UserPreferenceChangedEventArgs e)
	{
		switch(e.Category)
		{
			case UserPreferenceCategory.Locale:
				MessageBox.Show('Changed locale');
				break;
			default:
				MessageBox.Show(e.Category.ToString());
				break;
		}
	}

Share with

Share on twitter
Share on facebook
Share on linkedin

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.