loadLibrary with relative path/ findFile with relative path

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
ndhaiAsked:
Who is Participating?
 
ndhaiConnect With a Mentor Author Commented:
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
 
AndyAinscowFreelance programmer / ConsultantCommented:
..\dll

the .. moves one UP the directory path - into C:\\  lib and dll are not subdirectories of that.
0
 
ndhaiAuthor Commented:
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
 
AndyAinscowFreelance programmer / ConsultantCommented:
Use the full path instead.


0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.