Reputation: 104
So, I have currently a lot of projects on my computer all using the same library. What bugs me is they all have to have the same DLL in their respective folders. Granted, I don't need to copy them manually(My compiler does the job for me), but that's not the problem. The problem is I have ~25 copies of the same, huge DLL lying around.
So I was wondering if I could define a path variable with the DLL or something of that kind, so that upon execution, the program can find it at a precise point. The thing is, since I sometimes pass these projects to others, it would need to work with the dynamic link library just inside the folder and not elsewhere. And of course, if there is an app that I download using the same library but another version, of course it should not priorize the DLL I defined the path to but the one bundled with it.
So, in summary, I need my programs that can't find a DLL in their folders to fall back on a precise, predefined directory to find it.
I'm not sure it is possible. Any help would be greatly appreciated, and already, thank you for reading this.
Upvotes: 0
Views: 66
Reputation: 104524
For local development, easiest way is to just have a copy of the DLL in your PATH environment. The cheesiest way, although not recommended for customers, is to just copy the DLL to your your System directory. That is, copy it into c:\windows\system32
or c:\windows\syswow64
. Perfectly fine for development purposes.
Or create a custom folder just to hold a copy of this DLL. Update your Windows PATH via Control Panel to point to this directory that has the DLL.
Or use an App Paths registry key to amend the PATH for a specific EXE.
All of these solutions have a versioning issue, which may or may not be a problem for local development.
For distributing code to customers, just have the EXE and dependent DLLs in the same folder is the most tried and true method.
Also, read this: https://learn.microsoft.com/en-us/windows/win32/dlls/dynamic-link-library-search-order
Upvotes: 1