Can I use two incompatible versions of the same DLL in the same process?

前端 未结 7 1181
孤独总比滥情好
孤独总比滥情好 2020-12-31 11:45

I\'m using two commercial libraries that are produced by the same vendor, called VendorLibA and VendorLibB. The libraries are distributed as many DLLs that depend on the com

7条回答
  •  借酒劲吻你
    2020-12-31 11:55

    I'm no expert in DLLs, but the only way I see it possible would be to use LoadLibrary() and explicitly load the DLLs. Then you could place the functions/classes etc in separate namespaces using GetProcAddress().

    HMODULE v1 = LoadLibrary(_T("libv1_0.dll"));
    libv1_0::fun_in_lib = reinterpret_cast(GetProcAddress(v1, _T("fun_in_lib"));
    

    and

    HMODULE v2 = LoadLibrary(_T("libv2_0.dll"));
    libv2_0::fun_in_lib = reinterpret_cast(GetProcAddress(v2, _T("fun_in_lib"));
    

    Whether this would work or not still kind of depends on the library, so it may or may not work, but as far as I can tell it's the only possibility.

提交回复
热议问题