Share via


Multilingual User Interface (MUI) Registry Settings (Windows Embedded CE 6.0)

1/6/2010

The following table shows the registry settings for the HKEY_CURRENT_USER\MUI registry key.

Value : type Description

CurLang : REG_DWORD

Specifies the language identifier (LCID) for the current user.

Enable : REG_DWORD

Default set to 1. Setting this value to 1 enables MUI on the run-time image; setting this value to 0 disables MUI on the run-time image.

SysLang : REG_DWORD

No default is set. Specifies the system default language identifier (LCID).

MUI Registry

The MUI registry enables you to store localizable strings. These strings were traditionally stored in the resource section of a applicable module, such as a .dll or an .exe file. This mechanism extends the functionality of the MUI Catalog item. The MUI registry enables you to have one registry entry that points to several localized strings with the active value being based on the current locale settings.

To create a registry entry for a localizable string

  1. Using Notepad, open the .reg file where the registry settings for the applicable module are stored.

  2. Create a registry entry of type REG_MUI_SZ for each string. Each registry entry must list the module containing the localized content, and the resource ID of the string. Use the following syntax:

    "ValueName"=mui_sz:"<dll name>, #<resource id>"
    

    For example, to create a registry entry for the localized version of the string "Folder", add the following registry entry to the .reg file:

    "Folder"=mui_sz:"MySample.dll,#20"
    

Setting the value to MySample.dll,#20 implies that the localized version of the string is stored as resource #20 in the MySample.dll module.

To retrieve the value of a localized string from the registry, an application must call the RegQueryValueEx or RegEnumValue functions. The registry will automatically locate the appropriate MUI module, load the string, and return it to the application. The registry type will be set to REG_SZ on return of the function call.

To overwrite an existing registry value, an application must call the RegSetValueEx function. Overwriting the REG_MUI_SZ value with a value of type REG_SZ will replace the MUI registry value with the specified constant registry value. This new value will be applied to all locale settings.

To read the formatted MUI specification string that has been specified in the registry, an application should preset the value type to REG_MUI_SZ before calling RegQueryValueEx. To change the MUI specification, an application can also set the value type to REG_MUI_SZ when it calls RegSetValueEx. You must format the registry value using the appropriate syntax described in Step 2.

Note

The MUI registry method may not apply to certain localizable string elements, such as desktop shortcuts and driver names.

The following code samples demonstrate the correct use of types when creating the key, creating a value, querying the value, and loading the resource string. The point of this sample is to demonstrate that you should treat the REG_MUI_SZ object like a normal registry key. If you set the type parameter to REG_MUI_SZ, the resource will not be loaded.

The following sample shows how to create or open the registry key where a REG_MUI_SZ value will be stored by using RegCreateKeyEx.

HKEY OpenedKey = NULL;
DWORD CreationDisposition = 0;

LONG lReturn = RegCreateKeyEx(
    HKEY_LOCAL_MACHINE, 
    L"\\NewKey\\", 
    0,
    NULL,
    0,
    0,
    NULL,
    &OpenedKey,
    &CreationDisposition);

The value of lReturn should be ERROR_SUCCESS if everything was created correctly.

The following code sample demonstrates how to create a REG_MUI_SZ value, after creating the registry key above so as to set OpenedKey. Note that the Type parameter is set to REG_MUI_SZ.

DWORD DataSize = 0;
StringCbLength(L"regmui.dll,#1001", MAX_PATH, (size_t *)&DataSize)

LONG lReturn = RegSetValueEx(
    OpenedKey, 
    L"RegMuiExample", 
    0,
    REG_MUI_SZ,
    (BYTE *)L"regmui.dll,#1001",
    DataSize);

The following code sample demonstrates how to query the REG_MUI_SZ string that was just set. Again, the Type parameter is set to REG_MUI_SZ.

DWORD Type = REG_MUI_SZ;
LPWSTR DataBuffer = (LPWSTR)LocalAlloc(LPTR, MAX_PATH);
LONG lReturn = RegQueryValueEx (
    OpenedKey, 
    L"RegMuiExample", 
    0,
    &Type, 
    (BYTE *)DataBuffer,
    &DataSize);

Finally, the following code sample demonstrates how to load the resource string set in the previous examples. Note that in this call, the Type parameter is set to 0.

DWORD Type = 0;
LONG Return = RegQueryValueEx (
    OpenedKey, 
    L"RegMuiExample", 
    0,
    &Type, 
    (BYTE *)DataBuffer,
    &DataSize);

See Also

Other Resources

Multilingual User Interface (MUI)