我如何确定 Ruby-FFI 和 VB.net 无法加载 dll 文件的原因?

How do I identify why Ruby-FFI and VB.net can't load a dll file?

我有一个文件,其中包含我需要使用的四个函数。 DLL函数文档为here。我已经尝试用 VB.net 中的 Lib 和 Ruby-FFI 中的 ffi_lib 加载 DLL。两者都给我加载 DLL 的错误,但我无法使用任何东西来弄清楚为什么它不能加载 DLL。如何确定为什么 FFI(我的首选访问方法,但我也接受 VB.net)无法加载 DLL? Windows 和 Mac.

我都试过了

DLL 文件可用 here or by installing the file at number 5 on the support page here http://www.mscashdrawer.com/techcashdrawerUSB.php。这将创建一个 C:\Program Files\M-S Cash Drawer 目录,其中将包含 DLL 文件。

Ruby-FFI 在 mac 上说

/Users/brandoncc/dev/open_cash_drawer/MSPOS_USB.dll: unknown file type, first eight bytes: 0x4D 0x5A 0x90 0x00 0x03 0x00 0x00 0x00

更新:我想可能是因为dll是32位的。以下是来自dumpbin

的headers
Dump of file .\dev\open_cash_drawer\MSPOS_USB.dll

PE signature found

File Type: DLL

FILE HEADER VALUES
             14C machine (x86)
               4 number of sections
        53978AFD time date stamp Tue Jun 10 14:47:25 2014
               0 file pointer to symbol table
               0 number of symbols
              E0 size of optional header
            2102 characteristics
                   Executable
                   32 bit word machine
                   DLL

OPTIONAL HEADER VALUES
             10B magic # (PE32)
            9.00 linker version
            1800 size of code
            1200 size of initialized data
               0 size of uninitialized data
            1AE4 entry point (10001AE4)
            1000 base of code
            3000 base of data
        10000000 image base (10000000 to 10005FFF)
            1000 section alignment
             200 file alignment
            6.01 operating system version
            6.01 image version
            5.01 subsystem version
               0 Win32 version
            6000 size of image
             400 size of headers
            7714 checksum
               3 subsystem (Windows CUI)
             140 DLL characteristics
                   Dynamic base
                   NX compatible
           40000 size of stack reserve
            1000 size of stack commit
          100000 size of heap reserve
            1000 size of heap commit
               0 loader flags
              10 number of directories
            2710 [      9D] RVA [size] of Export Directory
            232C [      64] RVA [size] of Import Directory
            4000 [     3D0] RVA [size] of Resource Directory
               0 [       0] RVA [size] of Exception Directory
               0 [       0] RVA [size] of Certificates Directory
            5000 [     1C8] RVA [size] of Base Relocation Directory
            10B0 [      1C] RVA [size] of Debug Directory
               0 [       0] RVA [size] of Architecture Directory
               0 [       0] RVA [size] of Global Pointer Directory
               0 [       0] RVA [size] of Thread Storage Directory
            1138 [      40] RVA [size] of Load Configuration Directory
               0 [       0] RVA [size] of Bound Import Directory
            1000 [      9C] RVA [size] of Import Address Table Directory
               0 [       0] RVA [size] of Delay Import Directory
               0 [       0] RVA [size] of COM Descriptor Directory
               0 [       0] RVA [size] of Reserved Directory


SECTION HEADER #1
   .text name
    17AD virtual size
    1000 virtual address (10001000 to 100027AC)
    1800 size of raw data
     400 file pointer to raw data (00000400 to 00001BFF)
       0 file pointer to relocation table
       0 file pointer to line numbers
       0 number of relocations
       0 number of line numbers
60000020 flags
         Code
         Execute Read

  Debug Directories

        Time Type        Size      RVA  Pointer
    -------- ------- -------- -------- --------
    53978AFD cv            73 00001180      580    Format: RSDS, {6AFEFF09-4F33-4F1A-AE27-CA8FB3D57A60}, 1, d:\current\mscashdrawer\mscashdrawercontroller\mspos_dll\objfre_wxp_x86\i386\MSPOS_USB.pdb

SECTION HEADER #2
   .data name
     70C virtual size
    3000 virtual address (10003000 to 1000370B)
     400 size of raw data
    1C00 file pointer to raw data (00001C00 to 00001FFF)
       0 file pointer to relocation table
       0 file pointer to line numbers
       0 number of relocations
       0 number of line numbers
C0000040 flags
         Initialized Data
         Read Write

SECTION HEADER #3
   .rsrc name
     3D0 virtual size
    4000 virtual address (10004000 to 100043CF)
     400 size of raw data
    2000 file pointer to raw data (00002000 to 000023FF)
       0 file pointer to relocation table
       0 file pointer to line numbers
       0 number of relocations
       0 number of line numbers
40000040 flags
         Initialized Data
         Read Only

SECTION HEADER #4
  .reloc name
     47C virtual size
    5000 virtual address (10005000 to 1000547B)
     600 size of raw data
    2400 file pointer to raw data (00002400 to 000029FF)
       0 file pointer to relocation table
       0 file pointer to line numbers
       0 number of relocations
       0 number of line numbers
42000040 flags
         Initialized Data
         Discardable
         Read Only

  Summary

        1000 .data
        1000 .reloc
        1000 .rsrc
        2000 .text

原来我是想在64位系统上使用32位的dll。我希望这对其他人有帮助!