SatDLL Sample: Implements Multilingual Resources in a Win32 Application
The SatDLL sample demonstrates a number of things related to localization and globalization:
How to set up a solution that builds one main EXE file and individual satellite DLLs containing different language versions of the user interface.
The recommended way to implement a satellite DLL-loading mechanism with language fallback in case the selected language isn't available.
Code to detect the preferred language for the user interface on any version of Windows.
How to dynamically switch the user interface language upon a change request from a user (what is not demonstrated is how the user choice for the user interface language can be persisted).
How to use the generic character encoding mapping functions to be able to build ANSI and Unicode versions of an application from the same source code.
This sample code is provided to illustrate a concept and should not be used in applications or Web sites, as it may not illustrate the safest coding practices. Microsoft assumes no liability for incidental or consequential damages should the sample code be used for purposes other than as intended.
To get samples and instructions for installing them:
On the Visual Studio Help menu, click Samples.
For more information, see Visual Studio Samples.
The most recent version and complete list of samples is available online from the Visual Studio 2008 Samples page.
You can also locate samples on your computer's hard disk. By default, samples and a Readme file are copied into a folder under \Program Files\Visual Studio 9.0\Samples\. For Express editions of Visual Studio, all samples are located online.
Building and Running the Sample
To build and run this sample
Open the solution file satdll.sln.
From the Build menu, click Build Solution.
From the Debug menu, click Start Without Debugging.
In the default configuration, this solution builds a Unicode application which requires Windows 2000 or later with language support for Western European languages and Japanese installed to display all characters in the user interface correctly.
By changing the Character Set in the general project settings to "Use Multi-Byte Character Set" the sample can be compiled for earlier Windows platforms. You will only be able to switch between languages which are supported by the ANSI codepage for that earlier Windows version though.
When debugging this sample, the current directory is the solution directory and not the Debug directory. For this reason, the directories for the satellite DLLs (1031, 1033, and 1041) are created in the solution directory. When you deliver your application to an end-user, these satellite DLL directories should, of course, be created in the directory where the main executable file is located.
This sample demonstrates the following keywords:
LoadString; LoadMenu; LoadAccelerators; LoadIcon; LoadCursor; DialogBox; CreateFontIndirect; DrawText; InvalidateRect; UpdateWindow; DestroyMenu; SetMenu; DrawMenuBar; GetLocaleInfo; GetCurrentDirectory; FindFirstFile; FindNextFile; LoadLibrary; EnumResourceLanguages; GetVersionInfoEx; RegOpenKeyEx; RegQueryValueEx; RegCloseKey; GetUserDefaultUILanguage; GetUserDefaultLangID; _tWinMain; _tcscpy; _tcsncpy; _tcslen; _tcsclen; _tcscat; _ttoi; _itot