?
Solved

loadLibrary with relative path/ findFile with relative path

Posted on 2009-12-23
4
Medium Priority
?
1,507 Views
Last Modified: 2013-11-23
Hello,
My C++ application will be compiled to DLL (name MYAPP.dll). Then I put this dll to another folder.
In my application, I need to load another dll, then I call like this
HMODULE m_Lib = LoadLibrary(_T("..\dll\ANOTHER.dll"));
The m_Lib is NULL.
The same thing as using findFile
CFileFind finder;
BOOL finding = finder.FindFile (CString("..\lib\*.jar"));
The result is always FALSE
My directory structure like this
C:\Test\MYAPP.DLL
C:\Test\dll\ANOTHER.dll
C:\Test\lib\a.jar
C:\Test\lib\b.jar

Thanks for your help
0
Comment
Question by:ndhai
  • 2
  • 2
4 Comments
 
LVL 45

Expert Comment

by:AndyAinscow
ID: 26113445
..\dll

the .. moves one UP the directory path - into C:\\  lib and dll are not subdirectories of that.
0
 

Author Comment

by:ndhai
ID: 26113737
You're right, but althought I modify to .\dll, \dll, and dll, it doesnt work.
The problem is that, the current directory is not C:\Test, it is C:\Document and Setting\username, so the dll directory is not the sub directory of the current directory.
Anyone has an idea?
Thanks
0
 
LVL 45

Expert Comment

by:AndyAinscow
ID: 26114245
Use the full path instead.


0
 

Accepted Solution

by:
ndhai earned 0 total points
ID: 26118822
I found the a solution like that:
//get the dll path, that will return CString
LPTSTR  strDLLPath = new TCHAR[_MAX_PATH];
GetModuleFileName((HINSTANCE)&__ImageBase, strDLLPath, _MAX_PATH);
PathRemoveFileSpec(strDLLPath);
HMODULE m_Lib = LoadLibrary(strDLLPath + CString("/dl/ANOTHER.dlll"));
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses
Course of the Month13 days, 9 hours left to enroll

750 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