问题
I have a third-party DLL that depends on MSVCR80 and allocates resources that I need to cleanup. The library does not expose a free
-function for doing this. Instead, I need to load the same runtime library and manually call the free
function.
As a workaround I'm trying to write a "wrapper" DLL that loads the correct runtime and exposes the free
function. This DLL is created using Visual Studio 2010 and is dependent on a separate runtime library. Doing LoadLibrary("msvcr80.dll")
fails with error R6034 which I guess is because of manifest issues.
Is it even possible to load msvcr80.dll using LoadLibrary
? Do I need to create a manifest, embed it into the DLL and store msvcr80.dll in the same directory as my wrapper DLL?
I realize that this is a flaw in the third-party library, but I'm pretty much stuck with this version. Getting the vendor to fix this is most likely not an option.
回答1:
Probably there are better solutions, but in case everything else failed you could find somewhere a copy of VC++ 2005 Express Edition (=free, no piracy is needed ;)
), which uses the version 8.0 of the compiler, and thus the same runtime of the defective dll.
Then you would build your wrapper dll with it, which would just call the free
provided by its CRT (double check that you're using the dll version!).
来源:https://stackoverflow.com/questions/7419544/writing-a-dll-that-loads-msvcr80-dll-and-exposes-the-free-function