0

I recently discovered that WMi is localized. This means that my WQL queries and returned results are sometimes incorrect because of commas/dots in numbers. Since there are many users with German/French/Japanese windows, this must be a problem encountered quite often.

How can I communicate with WMI without needing a special case for every language mutation of Windows?

Update: Based on RRUZ's answer and a couple aricles I found online, it appears that the localized information is stored in a child namespace containing a localization identifier. There are two thing which are still unclear to me.

  1. It appears that the basic class on French Windows already returns numbers with decimal commas intead of dots. Does that mean that the default locale used is always the one of the system?
  2. The behavior described in the previous question makes me wonder where are the numbers converted from one system to another? Could it be happening in the framework itself?
  3. Is there a common locale which is present on all Windows instances? From what I've read, it seems that I cannot just expect to request any locale and get localized results.
JohnEye
  • 6,436
  • 4
  • 41
  • 67

1 Answers1

1

The Localization of the WMI is explained in the MSDN Documentation Localizing WMI Class Information.

WMI implements a technique that allows multiple localized versions of the same class to be stored in the repository.

The class definition is separated into the following versions:

* A language-neutral version that contains only a basic class definition.
* A language-specific version that contains localized information, such as property descriptions that are specific to a locale.

The language-specific class definitions are stored in a child namespace beneath the namespace that contains a language-neutral basic class definition.

When you request a localized class definition for a specific locale, WMI combines the basic class definition and the localized class information to form a complete localized class. You can get a localized version of a WMI class by specifying a locale when you connect to WMI and setting a flag that indicates that you want localized information. WMI then merges the information from the language-neutral and the language-specific versions of the class definition to form a localized class.

WMI classes that contain localized information are marked with the Amendment qualifier and are called amended classes; a class supports localized information if it has this qualifier. You can determine which locale the class has been localized for by checking for another qualifier called Locale. The locale qualifier contains a localization identifier (Windows LCID) that identifies a locale. For example, the locale for American English is 0x409. If a qualifier in an amended class contains localized information, it contains the amended qualifier flavor.

So depending of the language and framework which you are using to access the WMI you can set the ConnectionOptions.Locale Property to access a english version of the WMI repository.

ConnectionOptions options = new ConnectionOptions();
options.Locale = "MS_409"; 
ManagementScope scope = new ManagementScope("\\\\FullComputerName\\root\\cimv2", options);
scope.Connect();
RRUZ
  • 134,889
  • 20
  • 356
  • 483
  • Thank you for the answer. However, since I'm not going to be using .NET, there's a couple of thing that's not very clear to me. I updated the question, could you please take a look at it and see if you can shed more light onto it? – JohnEye Mar 13 '15 at 00:13