开发者

Which Win32 API reports the Format preference in the Region and Language control panel?

Windows 7 and Windows Vista have a Region and Language control panel which contains a Formats tab which contains a popup menu titled Format. This menu allows the user to select from among many language-oriented sets of number, currency, time, and date formatting preferences regardless of the language of the base system. For example, I could decide I prefer the default currency symbol to be Japanese yen on a US English system. I don't care about the currency symbol in particular; that was just an example. I'm referring here to the sets of preferences which may be applied by selecting items from the Format menu.

The Windo开发者_JS百科ws Contacts application appears to change its behavior based on the selection in this menu. For example, if I select Japanese, Windows Contacts displays and lets me edit phonetic names (AKA "ruby", "yomi", and "furigana") but not middle names. If I select US English, then Windows Contacts displays and lets me edit middle names but not phonetic names.

I need to write code (native C calling Win32 on XP SP2 and later) which mirrors the behavior of the Windows Contacts application in this respect. Which API should I call?


The question seems to combine two kinds of features.

Using the Control Panel applet, a general language setting can be selected and then individual formatting items are given default values associated with that language setting.

If you want to retrieve the user's overall language setting then just get the user's default LCID or something of that sort.

If you want to retrieve individual formatting items, I think you need the CRT function locale(). The Win32 API SetLocaleInfo can set the user overrideable portion of the locale. However, at least as documented, GetLocaleInfo and GetLocaleInfoEx (Vista and later only) get information associated with some existing locale rather than from user overrides. The standard C locale() function should work though.

Your question asks about how to retrieve individual formatting items, but then you say you have to key on the user's selected general locale instead of the individual formatting items. From your description of the Windows Contacts application, it sounds like you need GetUserDefaultLCID.


For most of these items, you can use functions like GetTimeFormat, GetNumberFormat, and GetCurrencyFormat. Contrary to what the names imply, these will actually format data as requested rather than just telling you what the format should be. Although you can specify a locale for them to use, you normally want to pass LOCALE_USER_DEFAULT, to use the settings the user has specified in the control panel.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜