我得到的ICLRRuntimeInfo实例是null C ++
DWORD pid = 2076;
HRESULT hr;
HANDLE hProcess;
ICLRMetaHost *pMetaHost = NULL;
IEnumUnknown *ppEnumerator = NULL;
ICLRRuntimeInfo *CLRRuntimeInfo = NULL;
ULONG pFetched = 0;
DWORD versionLength;
hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid);
if (hProcess == NULL) {
printf("process unable to open");
return 0;
}
hr = CLRCreateInstance(CLSID_CLRMetaHost, IID_ICLRMetaHost,*)&pMetaHost);
pMetaHost->EnumerateLoadedRuntimes(hProcess, &ppEnumerator);
if (ppEnumerator == 0) {
return 0;
}
hr = ppEnumerator->Next(1, (IUnknown **)&CLRRuntimeInfo, &pFetched);
if (hr == S_FALSE) {
printError(TEXT("CLRRuntimeInfo"));
return 0;
}
当我尝试使用EnumerateInstalledRuntimes时,得到所有已安装的运行时pMetaHost-> EnumerateInstalledRuntimes(&ppEnumerator)我得到的Windows错误:失败,错误18(没有更多文件)
在项目属性 - > VC ++目录 - >库目录 - > $(NETFXKitsDir)Lib \ um \ x86
但我正在用x64构建解决方案。现在改为x86。工作正常。