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
L"C:\Program Files (x86)\DLL path"
toL"C:\\Program Files (x86)\\DLL path"
LoadLibrary
line and then see what is up with the variable values? If not, are you familiar with the use of ProcMon.exe? Set an include filter to include all your exe-file names, flush all events, then set to record, launch the exe and see what errors you see in the file event list? I can try to write this up if you are not familiar with it. A rudimentary sample usage here.Options
=>Configure Module Search Order...
=>Uncheck "Expand" and press "Default"
=> will give you the most normal module search order (varies in each version of Windows).