[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 476
  • Last Modified:

DLL load path


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
BeerFizz
Asked:
BeerFizz
  • 3
  • 2
1 Solution
 
jkrCommented:
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
 
BeerFizzAuthor Commented:
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
 
BeerFizzAuthor Commented:

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
 
jkrCommented:
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
 
BeerFizzAuthor Commented:
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

Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now