0

I want to check current measurement units of OS and then set it to Metrics.

Thanks in advance!

Update:

I used following code in c#: Registry.SetValue(@"HKEY_CURRENT_USER\Control Panel\International", "iMeasuere", "0"); It sets registry value when I check by regedit but when I go back to Region and Language setting panel in OS I see that the Units system still is US and after that the registry key resets to "1"

Arash
  • 3
  • 2

2 Answers2

1

The Computer\HKEY_CURRENT_USER\Control Panel\International\iMeasure registry value contains the currently logged in regional settings for unit of measure, 1 for US, 0 for metrics. You can modify it with Registry.SetValue (Your app probably need to start as Administrator) Though I strongly suggest your app shouldn't do this automatically, you should be asking the user if they really want this since it will affect other apps.

Martheen
  • 5,198
  • 4
  • 32
  • 55
  • Thanks guys it solved my problem. – Arash Sep 24 '17 at 12:14
  • I used following code: Registry.SetValue(@"HKEY_CURRENT_USER\Control Panel\International", "iMeasuere", "0"); It sets registry value when I check by regedit but when I go back to Region and Language setting panel in OS I see that the Units system is US and after that the registry key resets to "1" – Arash Sep 24 '17 at 13:42
  • @Arash Can't replicate it here with latest Windows 10, VS 2017 and C# console app. Are you running the VS (if debugging) and the app as administrator? Try in another, clean PC. It's probable that Group Policy or other app interfere with the settings. – Martheen Sep 25 '17 at 03:06
0

I think this info is stored in the registry, and all other objects you would find down the road with that info are read-only. See the answer for this similar question which changes the info on the registry. Be aware this might change depending on the windows version, and some might require the user to log off.

On the other hand, I don't think is a good idea to force an application to display magnitudes in a particular unit of measure. In theory a user has chosen on settings the unit system he prefers. The "good way" to do it is to calculate everything you need on your units of choice, but present it to the user on his units of choice. Just a thought.

Overlord
  • 2,740
  • 2
  • 18
  • 22