bug 272166 : nsIWindowsShellService::getRegistryEntry does not support non-latin1 keys/values (r=mconnor, sr=darin, a=asa)
This commit is contained in:
@@ -37,7 +37,7 @@
|
||||
|
||||
#include "nsIShellService.idl"
|
||||
|
||||
[scriptable, uuid(eccda3b0-ea69-4066-8343-ddaf1f435b53)]
|
||||
[scriptable, uuid(5a92782c-a2e8-4dd3-b18a-33acc3af4fd7)]
|
||||
interface nsIWindowsShellService : nsIShellService
|
||||
{
|
||||
/**
|
||||
@@ -56,25 +56,5 @@ interface nsIWindowsShellService : nsIShellService
|
||||
* @return The number of unread (new) mail messages for the current user.
|
||||
*/
|
||||
readonly attribute unsigned long unreadMailCount;
|
||||
|
||||
/**
|
||||
* Valid starting keys for the Windows Registry.
|
||||
*/
|
||||
const long HKCR = 0; // HKEY_CLASSES_ROOT
|
||||
const long HKCC = 1; // HKEY_CURRENT_CONFIG
|
||||
const long HKCU = 2; // HKEY_CURRENT_USER
|
||||
const long HKLM = 3; // HKEY_LOCAL_MACHINE
|
||||
const long HKU = 4; // HKEY_USERS
|
||||
|
||||
/**
|
||||
* Retrieves a Windows Registry entry value.
|
||||
*
|
||||
* @param aHKeyConstant The starting key, using the constants defined above.
|
||||
* @param aSubKeyName The sub key to locate
|
||||
* @param aValueName The value to locate in the sub key. The empty string
|
||||
* returns the default value of the sub key.
|
||||
* @return The value of the specified sub key/value, truncated to 4096 bytes.
|
||||
*/
|
||||
string getRegistryEntry(in long aHKeyConstant, in string aSubKeyName, in string aValueName);
|
||||
};
|
||||
|
||||
|
||||
@@ -1009,54 +1009,6 @@ nsWindowsShellService::GetMailAccountKey(HKEY* aResult)
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWindowsShellService::GetRegistryEntry(PRInt32 aHKEYConstant,
|
||||
const char *aSubKeyName,
|
||||
const char *aValueName,
|
||||
char **aResult)
|
||||
{
|
||||
HKEY hKey, fullKey;
|
||||
|
||||
*aResult = 0;
|
||||
// Calculate HKEY_* base key
|
||||
switch (aHKEYConstant) {
|
||||
case HKCR:
|
||||
hKey = HKEY_CLASSES_ROOT;
|
||||
break;
|
||||
case HKCC:
|
||||
hKey = HKEY_CURRENT_CONFIG;
|
||||
break;
|
||||
case HKCU:
|
||||
hKey = HKEY_CURRENT_USER;
|
||||
break;
|
||||
case HKLM:
|
||||
hKey = HKEY_LOCAL_MACHINE;
|
||||
break;
|
||||
case HKU:
|
||||
hKey = HKEY_USERS;
|
||||
break;
|
||||
default:
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
// Open Key
|
||||
LONG rv = ::RegOpenKeyEx(hKey, aSubKeyName, 0, KEY_READ, &fullKey);
|
||||
|
||||
if (rv == ERROR_SUCCESS) {
|
||||
char buffer[4096] = { 0 };
|
||||
DWORD len = sizeof buffer;
|
||||
rv = ::RegQueryValueEx(fullKey, aValueName, NULL, NULL,
|
||||
(LPBYTE)buffer, &len);
|
||||
|
||||
if (rv == ERROR_SUCCESS)
|
||||
*aResult = PL_strdup(buffer);
|
||||
}
|
||||
|
||||
::RegCloseKey(fullKey);
|
||||
|
||||
return *aResult ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWindowsShellService::Observe(nsISupports* aObject, const char* aTopic, const PRUnichar* aMessage)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user