Fix a few more where we need to specify number of TCHARs rather than sizeof buffer
This commit is contained in:
parent
2fd3beab06
commit
f448bae54e
|
@ -40,7 +40,7 @@ JNIEXPORT jstring SIGAR_JNI(win32_LocaleInfo_getAttribute)
|
|||
int retval =
|
||||
GetLocaleInfo(lcid,
|
||||
attr,
|
||||
value, sizeof(value));
|
||||
value, sizeof(value) / sizeof(TCHAR));
|
||||
|
||||
if (retval) {
|
||||
int len = lstrlen(value);
|
||||
|
|
|
@ -431,8 +431,8 @@ JNIEXPORT jobjectArray SIGAR_JNI(win32_Pdh_pdhGetObjects)
|
|||
JNIEXPORT jstring SIGAR_JNI(win32_Pdh_pdhLookupPerfName)
|
||||
(JNIEnv *env, jclass cur, jint index)
|
||||
{
|
||||
TCHAR path[MAX_PATH];
|
||||
DWORD len = MAX_PATH; /* len is number of TCHAR's, not sizeof(path) */
|
||||
TCHAR path[MAX_PATH + 1];
|
||||
DWORD len = sizeof(path) / sizeof(TCHAR); /* len is number of TCHAR's, not sizeof(path) */
|
||||
PDH_STATUS status =
|
||||
PdhLookupPerfNameByIndex(NULL, index, path, &len);
|
||||
|
||||
|
|
|
@ -57,9 +57,10 @@ JNIEXPORT jstring SIGAR_JNI(win32_RegistryKey_RegEnumKey)
|
|||
{
|
||||
jstring strResult;
|
||||
TCHAR szBuffer[MAX_PATH + 1];
|
||||
DWORD len = sizeof(szBuffer) / sizeof(TCHAR);
|
||||
|
||||
if(RegEnumKey((HKEY)hkey, index, szBuffer,
|
||||
sizeof(szBuffer)) == ERROR_SUCCESS)
|
||||
len) == ERROR_SUCCESS)
|
||||
strResult = env->NewString((const jchar *)szBuffer,
|
||||
lstrlen(szBuffer));
|
||||
else
|
||||
|
@ -73,7 +74,7 @@ JNIEXPORT jstring SIGAR_JNI(win32_RegistryKey_RegEnumValueName)
|
|||
{
|
||||
jstring strResult;
|
||||
TCHAR szValueName[MAX_PATH + 1];
|
||||
DWORD cbValueName = sizeof(szValueName);
|
||||
DWORD cbValueName = sizeof(szValueName) / sizeof(TCHAR);
|
||||
|
||||
if(RegEnumValue((HKEY)hkey, index, szValueName,
|
||||
&cbValueName, NULL, NULL, NULL, NULL) == ERROR_SUCCESS)
|
||||
|
|
|
@ -303,7 +303,7 @@ int sigar_cpu_info_get(sigar_t *sigar, sigar_cpu_info_t *info)
|
|||
"HARDWARE\\DESCRIPTION\\System\\CentralProcessor", &key);
|
||||
|
||||
//just lookup the first id, then assume all cpus are the same.
|
||||
rc = RegEnumKey(key, 0, id, sizeof(id));
|
||||
rc = RegEnumKey(key, 0, id, sizeof(id)/sizeof(TCHAR));
|
||||
if (rc != ERROR_SUCCESS) {
|
||||
RegCloseKey(key);
|
||||
return rc;
|
||||
|
|
Loading…
Reference in New Issue