more fixes for ibm/websphere4 jdk
This commit is contained in:
parent
0bb1ba8711
commit
7362619bc1
|
@ -137,17 +137,27 @@ JNIEXPORT jint SIGAR_JNI(win32_RegistryKey_RegQueryIntValue)
|
||||||
DWORD dwType;
|
DWORD dwType;
|
||||||
LPBYTE lpValue;
|
LPBYTE lpValue;
|
||||||
DWORD cbValue;
|
DWORD cbValue;
|
||||||
|
LPTSTR copy;
|
||||||
|
jsize len = env->GetStringLength(valueName);
|
||||||
|
LPTSTR lpValueName = (LPTSTR)env->GetStringChars(valueName, NULL);
|
||||||
|
LONG lErr;
|
||||||
|
/* required under IBM/WebSphere 4.0 for certain keys */
|
||||||
|
if (lpValueName[len] != '\0') {
|
||||||
|
copy = wcsdup(lpValueName);
|
||||||
|
copy[len] = '\0';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
copy = lpValueName;
|
||||||
|
}
|
||||||
|
|
||||||
LPCTSTR lpValueName = (LPCTSTR)env->GetStringChars(valueName, NULL);
|
lErr = RegQueryValueEx((HKEY)hkey, copy,
|
||||||
LONG lErr = RegQueryValueEx((HKEY)hkey, lpValueName,
|
NULL, (LPDWORD)&dwType,
|
||||||
NULL, (LPDWORD)&dwType,
|
NULL, &cbValue);
|
||||||
NULL, &cbValue);
|
|
||||||
|
|
||||||
if(lErr == ERROR_SUCCESS) {
|
if(lErr == ERROR_SUCCESS) {
|
||||||
lpValue = (LPBYTE)HeapAlloc(GetProcessHeap(),
|
lpValue = (LPBYTE)HeapAlloc(GetProcessHeap(),
|
||||||
HEAP_ZERO_MEMORY, cbValue);
|
HEAP_ZERO_MEMORY, cbValue);
|
||||||
|
|
||||||
if(RegQueryValueEx((HKEY)hkey, lpValueName, NULL,
|
if(RegQueryValueEx((HKEY)hkey, copy, NULL,
|
||||||
NULL, lpValue, &cbValue) == ERROR_SUCCESS)
|
NULL, lpValue, &cbValue) == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
switch(dwType) {
|
switch(dwType) {
|
||||||
|
@ -169,6 +179,9 @@ JNIEXPORT jint SIGAR_JNI(win32_RegistryKey_RegQueryIntValue)
|
||||||
lErr = ERROR_SUCCESS - 1;
|
lErr = ERROR_SUCCESS - 1;
|
||||||
|
|
||||||
env->ReleaseStringChars(valueName, (const jchar *)lpValueName);
|
env->ReleaseStringChars(valueName, (const jchar *)lpValueName);
|
||||||
|
if (copy != lpValueName) {
|
||||||
|
free(copy);
|
||||||
|
}
|
||||||
|
|
||||||
if(lErr != ERROR_SUCCESS)
|
if(lErr != ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
|
@ -187,18 +200,28 @@ JNIEXPORT jstring SIGAR_JNI(win32_RegistryKey_RegQueryStringValue)
|
||||||
DWORD dwType;
|
DWORD dwType;
|
||||||
LPBYTE lpValue;
|
LPBYTE lpValue;
|
||||||
DWORD cbValue;
|
DWORD cbValue;
|
||||||
|
jsize len = env->GetStringLength(name);
|
||||||
|
LPTSTR lpValueName = (LPTSTR)env->GetStringChars(name, NULL);
|
||||||
|
LPTSTR copy;
|
||||||
|
LONG lErr;
|
||||||
|
/* required under IBM/WebSphere 4.0 for certain keys */
|
||||||
|
if (lpValueName[len] != '\0') {
|
||||||
|
copy = wcsdup(lpValueName);
|
||||||
|
copy[len] = '\0';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
copy = lpValueName;
|
||||||
|
}
|
||||||
|
|
||||||
LPCTSTR lpValueName = (LPCTSTR)env->GetStringChars(name, NULL);
|
lErr = RegQueryValueEx((HKEY)hkey,
|
||||||
LONG lErr = RegQueryValueEx((HKEY)hkey,
|
copy, NULL,
|
||||||
lpValueName, NULL,
|
(LPDWORD)&dwType, NULL, &cbValue);
|
||||||
(LPDWORD)&dwType, NULL, &cbValue);
|
|
||||||
|
|
||||||
if(lErr == ERROR_SUCCESS)
|
if(lErr == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
lpValue = (LPBYTE)HeapAlloc(GetProcessHeap(),
|
lpValue = (LPBYTE)HeapAlloc(GetProcessHeap(),
|
||||||
HEAP_ZERO_MEMORY, cbValue);
|
HEAP_ZERO_MEMORY, cbValue);
|
||||||
|
|
||||||
if(RegQueryValueEx((HKEY)hkey, lpValueName, NULL, NULL,
|
if(RegQueryValueEx((HKEY)hkey, copy, NULL, NULL,
|
||||||
lpValue, &cbValue) == ERROR_SUCCESS)
|
lpValue, &cbValue) == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
switch(dwType) {
|
switch(dwType) {
|
||||||
|
@ -228,6 +251,9 @@ JNIEXPORT jstring SIGAR_JNI(win32_RegistryKey_RegQueryStringValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
env->ReleaseStringChars(name, (const jchar *)lpValueName);
|
env->ReleaseStringChars(name, (const jchar *)lpValueName);
|
||||||
|
if (copy != lpValueName) {
|
||||||
|
free(copy);
|
||||||
|
}
|
||||||
|
|
||||||
if(lErr == ERROR_SUCCESS)
|
if(lErr == ERROR_SUCCESS)
|
||||||
return strResult;
|
return strResult;
|
||||||
|
|
Loading…
Reference in New Issue