change getStringValue to try EXPANDSZ_METADATA if STRING_METADATA fails

This commit is contained in:
Doug MacEachern 2005-09-23 00:12:58 +00:00
parent 1bc0ecade2
commit 236363efa8

View File

@ -178,28 +178,37 @@ JNIEXPORT jint SIGAR_JNI(win32_MetaBase_MetaBaseGetIntValue)
JNIEXPORT jstring SIGAR_JNI(win32_MetaBase_MetaBaseGetStringValue) JNIEXPORT jstring SIGAR_JNI(win32_MetaBase_MetaBaseGetStringValue)
(JNIEnv *env, jobject cur, jint key) (JNIEnv *env, jobject cur, jint key)
{ {
int i;
HRESULT hRes = 0; HRESULT hRes = 0;
METADATA_HANDLE MyHandle; METADATA_HANDLE MyHandle;
METADATA_RECORD MyRecord; METADATA_RECORD MyRecord;
DWORD dwBufLen = 8096; DWORD dwBufLen = 8096;
DWORD dwReqBufLen = 0; DWORD dwReqBufLen = 0;
TCHAR pbBuffer[8096]; TCHAR pbBuffer[8096];
DWORD data_types[] = {
STRING_METADATA,
EXPANDSZ_METADATA /* e.g. MD_LOGFILEDIRECTORY */
};
CComPtr <IMSAdminBase> *pIMeta; CComPtr <IMSAdminBase> *pIMeta;
pIMeta = (CComPtr <IMSAdminBase> *)env->GetLongField(cur, IMeta_field); pIMeta = (CComPtr <IMSAdminBase> *)env->GetLongField(cur, IMeta_field);
MyHandle = (METADATA_HANDLE)env->GetIntField(cur, ptr_field); MyHandle = (METADATA_HANDLE)env->GetIntField(cur, ptr_field);
for (i=0; i<sizeof(data_types)/sizeof(data_types[0]); i++) {
DWORD dtype = data_types[i];
// Initialize the input structure - // Initialize the input structure -
// the values specify what kind of data to enumerate. // the values specify what kind of data to enumerate.
MyRecord.dwMDIdentifier = key; MyRecord.dwMDIdentifier = key;
MyRecord.dwMDAttributes = 0; MyRecord.dwMDAttributes = 0;
MyRecord.dwMDUserType = IIS_MD_UT_SERVER; MyRecord.dwMDUserType = IIS_MD_UT_SERVER;
MyRecord.dwMDDataType = STRING_METADATA; MyRecord.dwMDDataType = dtype;
MyRecord.dwMDDataLen = dwBufLen; MyRecord.dwMDDataLen = dwBufLen;
MyRecord.pbMDData = (unsigned char *)pbBuffer; MyRecord.pbMDData = (unsigned char *)pbBuffer;
hRes = (*pIMeta)->GetData(MyHandle, TEXT(""), &MyRecord, &dwReqBufLen); hRes =
(*pIMeta)->GetData(MyHandle, TEXT(""), &MyRecord, &dwReqBufLen);
if (SUCCEEDED(hRes)) { if (SUCCEEDED(hRes)) {
jstring strResult; jstring strResult;
// Store the data identifiers in an array for future use. // Store the data identifiers in an array for future use.
@ -209,6 +218,7 @@ JNIEXPORT jstring SIGAR_JNI(win32_MetaBase_MetaBaseGetStringValue)
lstrlen(pbBuffer)); lstrlen(pbBuffer));
return strResult; return strResult;
} }
}
jclass cls = env->FindClass(WIN32_PACKAGE "Win32Exception"); jclass cls = env->FindClass(WIN32_PACKAGE "Win32Exception");
env->ThrowNew(cls, "No Such string value"); env->ThrowNew(cls, "No Such string value");
return NULL; return NULL;