获取ICLRRuntimeInfo实例是null C ++

时间:2017-12-12 09:03:59

标签: api debugging interop clr

我得到的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时,安装了所有Runtimes     pMetaHost-> EnumerateInstalledRuntimes(& ppEnumerator) 我得到的Windows错误:失败,错误18(没有更多文件)

1 个答案:

答案 0 :(得分:0)

In Project properties -> VC++ Directories -> Library Dirctories-> $(NETFXKitsDir)Lib\um\x86

But I'm building solution with x64. Now changed to x86. working fine.