Windows: implicitly linking DLL that is in a different folder

  .net-assembly, c++, config, dll, manifest

I am asking this question after VERY extensive googling, but there seem to be no comprehensive answer. I have a DLL which implicitly loads another (third-party) DLL. How can I create a manifest/config file/whatever, to load this third-party DLL from another folder?

Why I want to do this:
My C++ program (MSVC-compiled) needs to use a third-party DLL (I think it’s a .NET assembly, but I am really not knowledgeable in all this). I use #using "third party DLL.dll" to get access to the classes and functions of this DLL. Since it’s a .NET assembly, I can only do it from managed code. Since my main program is unmanaged C++, I create a managed DLL (compiled with /clr) that loads the third-party DLL, and then load this managed DLL dynamically. So it looks like this:

C++ program (unmanaged) -> [LoadLibrary()] -> My managed DLL -> [#using directive] -> third-party .DLL

Now, I want to distribute the whole thing to users, but I don’t like the license of the third-party .DLL. So what I am doing is asking the users to install another software package, which contains the third-party DLL, and then ask them to copy-paste it into the folder of my program. Would be a lot better, if it were possible to somehow tell Windows where to look for the third-party DLL, when my managed DLL is being loaded with LoadLibrary().

Any ideas how to solve this? Sorry if it’s a stupid question, I don’t understand all this DLL stuff.

Source: Windows Questions C++

LEAVE A COMMENT