Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Multilingual User Interface
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Resource Retrieval === Several win32 functions that read application resources are MUI-enabled, including LoadString, FormatMessage, and LoadImage.<ref>{{Cite web |last=Karl-Bridge-Microsoft |title=Loading Language Resources - Win32 apps |url=https://docs.microsoft.com/en-us/windows/win32/intl/loading-language-resources |access-date=2022-07-10 |website=docs.microsoft.com |language=en-us}}</ref> Each function attempts to read a resource for a language as selected by global language preferences, from application resources or associated MUI files (co-located with LN file and following naming convention). Each uses the global language preferences to choose a language that is available. If loading the resource for the first preferred language fails either because the MUI file does not exist or the resource does not exist in the MUI file, the function will try the next preferred language and so on until all preferences have been tried. If load fails for all preferred languages, then tries the LN file. The most commonly used function is LoadString which loads strings from a string-table resource. Example using LoadString: <syntaxhighlight lang="c"> wchar_t *resourceCharArray; int resourceLength = LoadStringW(moduleHandle, resourceId, (LPWSTR)&resourceCharArray, 0); if (!resourceLength) { MessageBoxW(NULL, L"Unable to find resource.", NULL, MB_ICONERROR); return -1; } wchar_t *text = (LPWSTR)malloc((resourceLength + 1) * sizeof(wchar_t)); wcsncpy(text, resourceCharArray, resourceLength); text[resourceLength] = L'\0'; // null terminate </syntaxhighlight> This retrieves the address of the resource text character buffer which is not guaranteed to be null terminated. Then, this copies the characters to a new buffer and appends a null terminator. Another option is to have LoadString copy the string to a passed buffer, but that requires using a fixed-length buffer which has downsides like usually allocating more than needed or truncation if too short. Oddly, MS documentation for LoadString does not mention its interaction with MUI -- use of language preference. FormatMessage is also MUI-enabled. Its function reference page describes its interaction with the user's language preference when parameter dwLanguageId is passed as 0. But FormatMessage reads from a ''message'' table, not a ''string'' table and as Raymond Chen says, "nobody actually uses message tables".<ref>{{Cite web |last=Chen |first=Raymond |date=2008-02-29 |title=Why can't I get FormatMessage to load my resource string? |url=https://devblogs.microsoft.com/oldnewthing/20080229-00/?p=23263 |access-date=2022-07-08 |website=The Old New Thing |language=en-US}}</ref>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)