1. Problem Description
During the product testing process, we noticed such a phenomenon, whether it is C ++ or a program developed with C #, which will exist when DLL is dynamically called: both a.exeand B .exe use loadlibrary (_ T ("deviceapi. DLL ") to call the deviceapi. DLL maps to the process space of the calling process. The handler actually maps deviceapi. DL in the folder rather than the B folder to its own process space.
2. Problem Analysis
In the loadlibrary Function Description in msdn, There is a description like this: "When Windows Embedded ce loads a DLL, all path information is ignored when determining if the DLL is already loaded. this means that a DLL with the same name but a different path can only be loaded once. in addition, a module ending with the extension. CPL is treated as if the extension is. DLL. ". Link: http://msdn.microsoft.com/en-us/library/ee488148 (V = winembedded.60). aspx. The handler specifies the dll path when calling loadlibrary, and wince will ignore it. This means that the DLL with the same name in different paths can only be loaded once for the wince system. The extension is CPL (control panel program) modules with the same name extension as DLL (loadlibrary can also load CPL modules ).
3. problem avoidance and Solution
Due to this limitation of the wince system, users are bound to be inconvenient. However, we only need to do the following to avoid this problem:
When you open a.exe, you can open B .exe. you can close a.exeand then open B .exe to avoid this problem. However, in some application scenarios, you may need to open both EXE files.
The same dlluses different names. For example, if deviceapia.dllis installed on a.x, B .exe loads deviceapib. dll, but in fact they all load deviceapi. dll.
These methods are just to avoid this problem, but there is no way to fundamentally solve these problems. If you know it, I hope to share it with you. Thank you!