I have two application and install in different folders, let call it app A and B, A is main application and B is an COM module, A will start B through COM API after A started, there are some DLLs need to be loaded by B while B started, if I start A by double click the shortcut of A, every thing is ok, but if I install A, and start A by check the start A option in the last dialog of the installation, then B is started, but one of the DLLs load failed with error code 126 (ERROR_MOD_NOT_FOUND), if I exit and restart again by double click the shortcut, it works again.
Already do some googles and seems the only difference between start from shortcut and installation is current directory, ie, if start from installation option, same as start from the installer package folder with cmd, like open cmd, switch to the folder of installer package, then start app A with full path, I have try this, also works well.
My installer package is build by installshield.
Is anyone have some clues about this issue?
- Already try to switch current directory to the install path of A and B, both can not solve this issue.
- Already try to set dll directory to the install path of B, which also is the path of the failed DLL, not work too.
- Already try to load the DLL with full path, also failed.
//SetCurrentDirectory(L"C:Program Files (x86)install path of A"); <<<not work
//SetCurrentDirectory(L"C:Program Files (x86)install paht of B"); <<<not work
//SetDllDirectory(L"C:Program Files (x86)DLL path"); <<<not work
//m_hLibrary = LoadLibrary((LPCWSTR)DLL full path); //not work
m_hLibrary = LoadLibrary((LPCWSTR)dllName.c_str()); //failed with error code 126
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…