Disable automatic DLL loading in C ++
My script looks like this: my application depends on a specific DLL (I am using lib while linking). However, when my application is running, I want to explicitly load this DLL using LoadLibrary. However, by default, when the code reaches the area that requires this DLL, the environment automatically searches for it and then loads it. I want to disable this behavior, and for me it doesn't matter if the application has reached the point where it wants to execute the code belonging to that DLL, I prefer it to crash automatically rather than load it automatically (so the DLL will only load because I explicitly called LoadLibrary).
In the meantime, I am using the latency ability (so the load trigger will only happen when the DLL needs to be loaded). However, I would prefer that the application just crash if the DLL hasn't loaded yet.
Is anyone perhaps familiar with a way to achieve this?
The load delay functionality will not load the dll until its first call to the function and not the scope. If you have global initializers that call this DLL, this might be why you think its scope is based. My company uses the technique of calling LoadLibrary before using it without issue. I suggest going deeper into your problem.
source to share
Is this what you need: http://msdn.microsoft.com/en-us/library/151kt790(VS.80).aspx ?
I mean, you can provide you a custom function to load the DLL and drop your application from there. It is detailed in the link provided.
source to share