简体   繁体   中英

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

Should Windows applications generally be able to distinguish between two DLLs with the same name, one being 32-bit and one being 64-bit, if they're in two separate paths in the system PATH variable?

Specifically right now, I have 32-bit and 64-bit DLLs for FreeImage, and they're in two separate folders, free_image_path\dist32 and free_image_path\dist64 , both of which I've added to the system PATH. However, application built to use them can't find either and I'm wondering if this is because there's two DLLs with the same name and they can't distinguish them.

I also tried putting the 32-bit and 64-bit DLLs in the windows\system and windows\SySWoW64 folders respectively, and that worked for the 32-bit app but not the 64-bit.

Thanks.

Windows can tell whether a given DLL is compiled for 32 bit or 64 bit platforms, but that won't help in the situation you describe. The DLL loader for your app process will stop looking as soon as it finds a DLL in the system path that fits the file name requirements for the DLL import. There are no other qualifications for matching code DLLs. (as noted in the comments, non-code resource DLLs are a different story. I suspect resource DLLs are not loaded by the core program loader but by a resource manager with different rules and objectives.)

If the first DLL in the path is 32 bit and your app is 32 bit, then the DLL load will work. If the app is 64 bit, it will fail to load the DLL and the process will abort.

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

As an alternative to putting the 64-bit dll in \windows\system32 and the 32-bit one in \windows\syswow64 , I have found that it also works if you put the 32-bit one in a subdirectory of \Program Files (x86) and the 64-bit one in the corresponding subdirectory of \Program Files , with both of those subdirectories included in PATH.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM