This article introduces the implementation of a multi-language approach, which is also recommended by Microsoft. Open the windows directory under Windows Mobile and you can see many files suffixed with Mui, such as shellres. dll.0804.mui, Shell. dll.0804.mui ...... You can use a File Viewer such as exescope.exe or resources hacker to check what these files are like. It is not difficult to find that the files contain resource IDs and corresponding strings. Maybe you are wondering why? What are the functions of these files? It is broken down below.
Mui is the abbreviation of multilingual user interface, which is a multilingual user interface. It is mainly used to internationalize software, that is, the implementation of multi-language software versions. In fact, a Mui file is also a DLL, but this DLL is a bit special. Unlike the previous introduction, it contains a lot of function bodies for calling outside the DLL or itself, instead, it only contains string resources. Therefore, you can create a DLL project under vs without any other code. The DLL entry point is as follows:
# Include "windows. H"
//////////////////////////////////////// /////////////////////////////////////
// DLL entry point
Extern "C"
Bool winapi dllmain (handle hinstance, DWORD dwreason, lpvoid lpreserved)
{
Return true;
}
In addition, as mentioned earlier, the DLL only contains string resources. Therefore, you must add a resource configuration file, such as ***. RC, to add the corresponding string resource information, as shown below:
Idr_hello_menubar menu discardable
Begin
Menuitem "exit", psp_dlgindirect
Popup "menu"
Begin
Menuitem "exit", psp_dlgindirect
Menuitem "test", id_menu_test
End
End
Pay special attention to this, because every Mui means that every DLL represents a language, therefore, in the resource configuration file, you can change the corresponding language of each string to achieve the effect of multiple languages. For example, to make a Simplified Chinese version, you must re-create a DLL, create a resource configuration file, but you have to change the above resource configuration script code to the following:
Idr_hello_menubar menu discardable
Begin
Menuitem "exit", psp_dlgindirect
Popup "menu"
Begin
Menuitem "exit", psp_dlgindirect
Menuitem "test", id_menu_test
End
End
Then, you can share the resource. h file that defines the resource ID so that multiple Mui files and applications use the same resource ID.
At the same time, you also need to add an export file such as ***. Def in the DLL project. In fact, you do not need to export the function name as follows:
Library "hello.exe. 0804.mui"
Exports
Maybe you will ask, how does the application locate the language by matching the Mui file? See.
. Then what does 0804 mean? The language ID defined by Microsoft is a hexadecimal number. For example, the ID of Simplified Chinese is 0x0804, while that of American English is 0409. For the language IDs of other countries, you can view the language identifiers and locales in the SDK.
How does the system identify which Mui file is used by the application? In the system registry, HKEY_CURRENT_USER \ Control \ Panel \ Desktop \ multiuilanguageid records the default language ID of the system. Therefore, the system automatically configures the default ID without the need for programmers to use code control. Note that the Mui files and applications must be stored in the same directory. When using vs to generate a Mui file, you can set the project properties so that vs can directly generate a Mui file, in the DLL project, "Project Properties" ---- "linker" ---- "output file" $ (outdir)/your_mui_name in "General", you only need to modify your_mui_name to your Mui file name.
Mui is used to implement multi-language implementation. without changing the application code, you only need to directly add or delete independent Mui files. The Mui files and applications are highly separated, easy to manage.