Can windows distinguish between 32-bit and 64-bit DLLs?

If Windows applications can usually distinguish between two DLLs with the same name, one of which is 32-bit and one of them 64-bit, if they are in two separate paths in the PATH variable of the system?

In particular, right now I have 32-bit and 64-bit libraries for FreeImage, and they are in two separate folders: free_image_path\dist32 and free_image_path\dist64 , both of which I added to the PATH system. However, the application created for their use cannot be found, and I wonder if this is because there are two libraries with the same name, and they cannot distinguish them.

I also tried placing 32-bit and 64-bit DLLs in the windows \ system and windows \ SySWoW64 folders, respectively, and this worked for a 32-bit application, but not for a 64-bit one.

Thanks.

+6
source share
2 answers

Windows can determine if this DLL is compiled for 32-bit or 64-bit platforms, but this will not help in the situation you describe. The DLL loader for your application process will stop looking as soon as it finds a DLL in the system path that matches the file name requirements for importing the DLL. There are no other qualifications for matching DLL code files. (As noted in the comments, DLL files with a non-code resource are a different story. I suspect that the resource libraries are not loaded by the main program loader, but by the resource manager with different rules and tasks.)

If the first DLL in the path is 32 bits, and your application is 32 bits, then the DLL will load. If the application is 64-bit, it will not be able to load the DLL, and the process will be interrupted.

If you want the two DLLs to coexist on the system path, you need to provide them with unique file names.

+8
source

As an alternative to hosting the 64-bit DLL in \windows\system32 and the 32-bit version in \windows\syswow64 , I found that it also works if you put 32-bit in the \Program Files (x86) subdirectory and 64-bit in the corresponding \Program Files subdirectory, both of which are included in the PATH.

+2
source

Source: https://habr.com/ru/post/890179/


All Articles