In VS2017 C++ windows application, I want to wait until runtime to choose the path to the openGL32.dll that is called.To facilitate this, I am purposely NOT positioning the openGL32.dll in my application’s folder in Program Files. Instead, I have positioned the openGL32.dll in a folder in the Public directory. So, at runtime, I’m wanting to decide whether to load the openGL32.dll that is in the Public directory, OR load the openGL32.dll that is in the system directory.
However, I’m having a lot of trouble getting this to work. Even though I can get the openGL32.dll in the public directory to successfully load, i cannot seem to stop the openGL32.dll that is in the system directory from ALSO loading.
The evidence that both openGL32.dlls are loading for my application is from dependency walker, the Output window in Visual Studio when running my application in the debugger, and also Process Explorer.
I should point out that in my application’s project settings, I am linking against opengl32.lib, glu32.lib, and glaux.lib.
Here are more details of how I am attempting to do this:
a) In the project settings for my application, I’ve listed the openGL32.dll under the field “Delay Loaded Dlls”.
b) I’ve deleted the openGL32.dll from my application’s directory in Program Files (C:\Program Files (x86)\MyApplication)
c) I’ve put a copy of openGL32.dll into my application’s folder in the Public directory (C:\Users\Public\Documents\MyApplication)
d) In my application’s source code, in the application constructor, I’d added the following two calls:
bResult = SetDllDirectory(“C:\Users\Public\Documents\MyApplicationr\OPENGL32.DLL”);
hLibrary = LoadLibrary(“C:\Users\Public\Documents\MyApplication\OPENGL32.DLL”);
bResult is TRUE;
hLibrary is a valid (not NULL) pointer.
So, with all of the above in place, I successfully get the OPENGL32.DLL in the public directory to be loaded at runtime.This is good. But again, the openGL32.dll in the system folder also gets loaded, which is bad.
Any help would be greatly appreciated!!!