Author: dchapyshev
Date: Sun Nov 23 02:19:35 2008
New Revision: 37574
URL:
http://svn.reactos.org/svn/reactos?rev=37574&view=rev
Log:
- Fix IsValidLanguageGroup and EnumSystemLanguageGroups. +102 passed tests
Modified:
trunk/reactos/dll/win32/kernel32/misc/lang.c
Modified: trunk/reactos/dll/win32/kernel32/misc/lang.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/misc/la…
==============================================================================
--- trunk/reactos/dll/win32/kernel32/misc/lang.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/misc/lang.c [iso-8859-1] Sun Nov 23 02:19:35 2008
@@ -50,22 +50,8 @@
LONG_PTR param;
} ENUM_UILANG_CALLBACK;
-static const WCHAR szLocaleKeyName[] =
-
-{
-
'M','a','c','h','i','n','e','\\','S','y','s','t','e','m','\\',
-
'C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\',
-
'C','o','n','t','r','o','l','\\','N','l','s','\\','L','o','c','a','l','e',0
-};
-
-static const WCHAR szLangGroupsKeyName[] = {
-
'M','a','c','h','i','n','e','\\','S','y','s','t','e','m','\\',
-
'C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\',
-
'C','o','n','t','r','o','l','\\','N','l','s','\\',
-
'L','a','n','g','u','a','g','e','
','G','r','o','u','p','s',0
-};
-
-extern const unsigned int CollationTable[];
+static const WCHAR szLocaleKeyName[] =
L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\NLS\\Locale";
+static const WCHAR szLangGroupsKeyName[] =
L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\NLS\\Language
Groups";
/******************************************************************************
* @implemented
@@ -378,6 +364,8 @@
}
FreeResource( hResource );
}
+ else DPRINT1("FindResourceExW() failed\n");
+
return bRet;
}
@@ -753,7 +741,7 @@
if (!hKey)
{
- DPRINT1("NLS_RegOpenKey() failed\n");
+ DPRINT1("NLS_RegOpenKey() failed, KeyName='%S'\n",
szLangGroupsKeyName);
return FALSE;
}
@@ -2291,82 +2279,37 @@
DWORD dwFlags)
{
static const WCHAR szFormat[] = { '%','x','\0' };
- UNICODE_STRING szNlsKeyName =
-
RTL_CONSTANT_STRING(L"\\REGISTRY\\Machine\\System\\CurrentControlSet\\Control\\Nls");
- UNICODE_STRING szLangGroupsKeyName =
- RTL_CONSTANT_STRING(L"Language Groups");
- const int MAX_VALUE_NAME = 16;
- const int MAX_VALUE_SYMB = 128;
-
- BOOL bNtQuery;
- PKEY_VALUE_PARTIAL_INFORMATION kvpiInfo;
-
- WCHAR szValueName[MAX_VALUE_NAME];
- UNICODE_STRING ucsValueName;
- DWORD dwRetSize;
- PWSTR pwszValueData;
-
- DWORD dwSize = sizeof(KEY_VALUE_PARTIAL_INFORMATION) + MAX_VALUE_SYMB *
sizeof(WCHAR);
-
- OBJECT_ATTRIBUTES oaAttr;
- HANDLE hkey, hRootKey;
+ WCHAR szValueName[16], szValue[2];
BOOL bSupported = FALSE, bInstalled = FALSE;
-
- DPRINT("IsValidLanguageGroup() called\n");
-
- kvpiInfo = RtlAllocateHeap(RtlGetProcessHeap(),
- HEAP_ZERO_MEMORY,
- dwSize);
+ HANDLE hKey;
+
switch (dwFlags)
{
- case LGRPID_INSTALLED:
- case LGRPID_SUPPORTED:
-
- InitializeObjectAttributes(&oaAttr, &szNlsKeyName, 0, 0, NULL);
- if(NtOpenKey(&hRootKey, KEY_ALL_ACCESS, &oaAttr) != STATUS_SUCCESS)
return FALSE;
-
- InitializeObjectAttributes(&oaAttr, &szLangGroupsKeyName, 0,
hRootKey, NULL);
- if(NtOpenKey(&hkey, KEY_ALL_ACCESS, &oaAttr) != STATUS_SUCCESS)
return FALSE;
-
- if(hRootKey) NtClose(hRootKey);
-
- swprintf(szValueName, szFormat, (ULONG)LanguageGroup);
- RtlInitUnicodeString(&ucsValueName, szValueName);
-
- bNtQuery = NtQueryValueKey(hkey,
- &ucsValueName,
- KeyValuePartialInformation,
- kvpiInfo,
- dwSize,
- &dwRetSize);
- if(hkey) NtClose(hkey);
-
- if(bNtQuery == STATUS_SUCCESS &&
- kvpiInfo->DataLength == sizeof(DWORD))
- {
- pwszValueData = (PWSTR)&kvpiInfo->Data[0];
- bSupported = TRUE;
- if(pwszValueData[0] == L'1') bInstalled = TRUE;
- }
- else
- {
- DPRINT("NtQueryValueKey() failed (Status %lx)\n", bNtQuery);
- RtlFreeHeap(RtlGetProcessHeap(), 0, kvpiInfo);
- return FALSE;
- }
+ case LGRPID_INSTALLED:
+ case LGRPID_SUPPORTED:
+
+ hKey = NLS_RegOpenKey( 0, szLangGroupsKeyName );
+
+ swprintf( szValueName, szFormat, LanguageGroup );
+
+ if (NLS_RegGetDword( hKey, szValueName, (LPDWORD)szValue ))
+ {
+ bSupported = TRUE;
+
+ if (szValue[0] == '1')
+ bInstalled = TRUE;
+ }
+
+ if (hKey)
+ NtClose( hKey );
break;
}
- RtlFreeHeap(RtlGetProcessHeap(), 0, kvpiInfo);
-
- if((dwFlags == LGRPID_SUPPORTED && bSupported) ||
- (dwFlags == LGRPID_INSTALLED && bInstalled))
- {
- DPRINT("Language group is supported and installed\n");
+ if ((dwFlags == LGRPID_SUPPORTED && bSupported) ||
+ (dwFlags == LGRPID_INSTALLED && bInstalled))
return TRUE;
- }
return FALSE;
}