HANDLE Proc;
HMODULE hDLL;
hDLL = LoadLibrary(TEXT("mscoree.dll"));
if(hDLL == NULL)
cout << "No Dll with Specified Name" << endl;
else
{
cout << "DLL Handle" << hDLL << endl<<endl;
cout << "Getting the process address..." << endl;
Proc = GetProcAddress(hDLL,"GetRequestedRuntimeVersion");
if(Proc == NULL)
{
FreeLibrary(hDLL);
cout << "Process load FAILED" << endl;
}
else
{
cout << "Process address found at: " << Proc << endl << endl;
LPWSTR st;DWORD* dwlength; ;DWORD cchBuffer=MAX_PATH;
HRESULT hr=GetCORSystemDirectory(st,cchBuffer,dwlength);
if(hr!=NULL)
{
printf("%s",hr);
}
FreeLibrary(hDLL);
}
}
Ich mochte dies, um den .NET-Installationspfad zu bekommen, aber ich erhalte Linker-Fehler.Wie verwende ich GetCORSystemDirectory()?
Fehler LNK2019: nicht aufgelöstes externes Symbol _GetCORSystemDirectory @ 12 in Funktion verwiesen _main dot.obj
Die if-Anweisung ist falsch. if (ptr! = 0) {// benutze} – sharptooth
@sharptooth: Danke! korrigiert es. – Indy9000
Lesen Sie die Dokumentation zu GetCORSystemDirectory, um zu verstehen, was es tut. Hier ist ein Link http://msdn.microsoft.com/en-us/library/k0588yw5(VS.71).aspx – Indy9000