Home > Software engineering >  DLL DLL dynamic invocation
DLL DLL dynamic invocation

Time:09-19

Exe dynamic invocation a. d. LL
A. d. LL also dynamic invocation B.D LL
A. d. LL and B.D LL path in the same layer, exe in a. d. a layer of LL



Exe calls a. d. LL methods:
M_hHandle=: : LoadLibraryEx (_T (a. d. "LL absolute path"), NULL, LOAD_WITH_ALTERED_SEARCH_PATH);


A. d. LL call B.D LL method
M_hHandle=: : LoadLibraryEx (_T (" B.D LL absolute path "), NULL, LOAD_WITH_ALTERED_SEARCH_PATH);


Exe layer calls LoadLibraryEx error GetLastError=0


If the a. d. LL in static load B.D LL, is good at exe layer calls



Have any good solution?

CodePudding user response:

Can have a try of the module itself at GetModuleFileName, file path name, and then constructs the B.D LL the absolute path

TCHAR szPath [MAX_PATH + 1)={0};
If (GetModuleFileName (AfxGetInstanceHandle (), szPath, MAX_PATT))
{
PathRemoveFileSpec (szPath);//remove the current module file name
PathAppend (szPath, _T (" B.D LL));//append B.D LL
HMODULE hDLLB=LoadLibrary (szPath);
If (hDLLB)
{
.
FreeLibrary (hDLLB);
}
}


CodePudding user response:

B what dependence lead to the failure load

CodePudding user response:

reference 1st floor zgl7903 response:
can have a try of the module itself at GetModuleFileName, file path name, and then constructs the B.D LL the absolute path

TCHAR szPath [MAX_PATH + 1)={0};
If (GetModuleFileName (AfxGetInstanceHandle (), szPath, MAX_PATT))
{
PathRemoveFileSpec (szPath);//remove the current module file name
PathAppend (szPath, _T (" B.D LL));//append B.D LL
HMODULE hDLLB=LoadLibrary (szPath);
If (hDLLB)
{
.
FreeLibrary (hDLLB);
}
}


According to your method is still the same error

CodePudding user response:

refer to the second floor oyljerry response:
what dependence lead to the failure load is B

Depends looked B.d ll dependent DLLS are all on the same level directory,

Exe layer calls LoadLibrary error GetLastError=1114

CodePudding user response:

1114 A dynamic link library (DLL) initialization routine failed.
Namely B.D LL DllMain returned to the FALSE, the specific reason of debugging or write the log to see

CodePudding user response:

reference 4 floor shedawei response:
Quote: refer to the second floor oyljerry response:

What is B dependence lead to the failure load

Depends looked B.d ll dependent DLLS are all on the same level directory,

Exe layer calls LoadLibrary error GetLastError=1114

Need to have a look at the entrance DllMain function call what, do what operation?
  • Related