Solved

DLL load path

Posted on 2011-09-21
5
434 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
C++ Language error 28 197
typedef std::deque<BYTE> ByteVector is broken in vs2012 23 82
please insert disk adobe master collection6 9 615
What .NET website keeps me current? 9 58
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

863 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now