Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

DLL load path

Posted on 2011-09-21
5
438 Views
Last Modified: 2013-12-04

Hi,

I have an issue with the 'correct' DLL being loaded on a target machine(s).

In some of the target machines, different versions of a DLL may have ben registered or placed in multiple/different folders.

I need to specifically be able to load a certain DLL.

I beleive it used to be that the folder from where the app was launched was searched first, but this is no longer the case due to the need to prevent hacks??  Is this the case?

How do I specify a specific DLL to be loaded?

Code examples if you have them, please.

Thanks
Phil
0
Comment
Question by:BeerFizz
  • 3
  • 2
5 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 36574902
Take a look at http://msdn.microsoft.com/en-us/library/ms682586%28VS.85%29.aspx ("Dynamic-Link Library Search Order"), which is an in-depth explanation on how that works in Windows. You might want to use 'LoadLibraryEx()' (http://msdn.microsoft.com/en-us/library/ms684179%28v=VS.85%29.aspx) with LOAD_WITH_ALTERED_SEARCH_PATH: "If this value is used and lpFileName specifies an absolute path, the system uses the alternate file search strategy discussed in the Remarks section to find associated executable modules that the specified module causes to be loaded."
0
 

Author Comment

by:BeerFizz
ID: 36574965
Hi jkr,

thanks for the response.

This particular DLL which is ebing loaded is loaded from a DLL in my app.  

Does DELAYLOAD have to be invoked?
0
 

Author Comment

by:BeerFizz
ID: 36575064

I'm not sure I framed my initial question correctly.

The DLL in question uses 'COM'.

When my application fails because the incorrect DLL is regestered, it is because the CLSID cannot be found or some varient of that.

Is it possible to bypass the registered DLL/CLSID and load the correct DLL directly?

Not sure if I'm making a lot of sense here...

0
 
LVL 86

Accepted Solution

by:
jkr earned 500 total points
ID: 36575600
COM is a whole different story. If the DLL in question is not registered properly, you should handle that as an error or register the DLL yourself either by calling regsvr32.exe or loading it using 'LoadLibrary()' and calling 'DllRegisterServer()' - see http://support.microsoft.com/kb/207132 ("INFO: How Regsvr32.exe Registers and Unregisters COM DLLs") for code that does that.
0
 

Author Closing Comment

by:BeerFizz
ID: 36910004
jkr,

thank you for your response and I apologize for how long it took me to get back.  I had to get info of the target machine and there were issues with that.

I am going to reframe my question and ask it again, if you would be so kind to look.

I will call it "C++ Com Problem".

Thanks
Phil
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question