Changeset 1370
- Timestamp:
- 11/30/2009 1:55:19 AM (3 years ago)
- Location:
- trunk/eraser6/ShellExt
- Files:
-
- 2 edited
-
CtxMenu.cpp (modified) (2 diffs)
-
stdafx.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/eraser6/ShellExt/CtxMenu.cpp
r1369 r1370 662 662 } 663 663 664 LCID LocaleNameToLCID(const std::wstring& localeName) 665 { 666 LCID result = LOCALE_USER_DEFAULT; 667 IMultiLanguage* multiLanguage = NULL; 668 669 //Create an instance of the IMultiLanguage interface 670 if (SUCCEEDED(CoCreateInstance(CLSID_CMultiLanguage, NULL, CLSCTX_ALL, 671 IID_IMultiLanguage, (void**)&multiLanguage))) 672 { 673 //Convert our locale name to a BString 674 BSTR localeNameBStr = SysAllocString(localeName.c_str()); 675 if (localeNameBStr) 676 multiLanguage->GetLcidFromRfc1766(&result, localeNameBStr); 677 SysFreeString(localeNameBStr); 678 679 //Clean up 680 multiLanguage->Release(); 681 } 682 683 return result; 684 } 685 664 686 std::wstring CCtxMenu::LoadString(UINT stringID) 665 687 { 666 688 //Convert the resource ID to the block and item IDs. 667 UINT stringBlockId = (stringID >> 4) + 1; 668 UINT stringItemId = stringID % 16; 689 UINT stringBlockID = (stringID >> 4) + 1; 690 UINT stringItemID = stringID % 16; 691 WORD langID = LANG_USER_DEFAULT; 692 std::wstring localeName; 693 694 if (localeName.empty()) 695 { 696 Handle<HKEY> eraserKey; 697 LONG openKeyResult = RegOpenKeyEx(HKEY_CURRENT_USER, 698 L"Software\\Eraser\\Eraser 6\\3460478d-ed1b-4ecc-96c9-2ca0e8500557\\", 0, 699 KEY_READ, &static_cast<HKEY&>(eraserKey)); 700 701 if (openKeyResult == ERROR_NOT_FOUND) 702 { 703 //The language value was not defined, maintain defaults. 704 localeName.insert(localeName.begin(), 1, L'\0'); 705 } 706 else 707 { 708 //Check the value of the Language value. 709 std::vector<wchar_t> value(256); 710 for ( ; ; ) 711 { 712 DWORD valueType = 0; 713 DWORD valueSize = value.size(); 714 DWORD error = RegQueryValueEx(eraserKey, L"Language", NULL, &valueType, 715 reinterpret_cast<BYTE*>(&value.front()), &valueSize); 716 717 if (error == ERROR_SUCCESS) 718 break; 719 else 720 switch (error) 721 { 722 case ERROR_INSUFFICIENT_BUFFER: 723 value.resize(value.size() * 2); 724 break; 725 } 726 } 727 728 localeName.assign(value.begin(), value.end()); 729 langID = LANGIDFROMLCID(LocaleNameToLCID(localeName)); 730 } 731 } 669 732 670 733 //Obtain a pointer to the memory holding the string table. 671 734 HRSRC resourceHandle = FindResourceEx(theApp.m_hInstance, 672 RT_STRING, MAKEINTRESOURCE(stringBlockI d), MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL));735 RT_STRING, MAKEINTRESOURCE(stringBlockID), langID); 673 736 if (!resourceHandle) 674 737 AfxMessageBox(FormatError().c_str()); … … 683 746 //Iterate over the string table. The string table is null-delimited with 684 747 //the first byte storing the length of the string entry. 685 for ( ; stringItemI d != 0; --stringItemId)748 for ( ; stringItemID != 0; --stringItemID) 686 749 { 687 750 if (*stringTable == L'\0') -
trunk/eraser6/ShellExt/stdafx.h
r1360 r1370 40 40 41 41 #include <shellapi.h> 42 #include <MLang.h> 42 43 43 44 //Other STATUS constants from ntstatus.h (not included from windows.h)
Note: See TracChangeset
for help on using the changeset viewer.
