Solved

DLL load path

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

776 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