Re: wxEuphoria cannot load library even if libwxeu.dll is present in path
- Posted by petelomax Mar 06, 2018
- 1563 views
irv said...
Here's an attempt to determine 32/64 bit dlls programatically. I've tested it with a few, it seems to work. Needs to be run from the folder where the dll lives:
constant dllname = "atl.dll" -- or whatever; include std/io.e include std/filesys.e include std/console.e include std/sequence.e if not file_exists(dllname) then display("[] can't be found!",{dllname}) abort(1) end if object buffer = {} atom fn = open(dllname,"rb") if fn then buffer = get_bytes(fn,1000) integer x = match({80,69},buffer) if find('L',buffer[x..$]) = 5 then display("x86 (32-bit)") end if if match({#64,#86},buffer[x..$]) = 5 then display("x64 (64-bit)") end if else display("Failed to open []",{dllname}) end if
Looks about right to me.
I would however test for buffer[#80..#83]={'P','E',0,0} rather than that (equivalent) match, and that buffer[#84..#85]={#4C,#01} is 32bit and buffer[#84..#85]={#64,#86} is 64bit.
For a linux equivalent, if a .so file starts with {#7F,'E','L','F',#01} it is 32 bit and if {#7F,'E','L','F',#02} it is 64 bit.
Be warned I didn't actually test any of that though.
Pete