4

What is the easiest way to use a custom DLL from within Ruby ?

In Python I would use ctypes, just as described as in this example. But now how should I do it in Ruby, preferably using native functionalities over third party libs ? Is there any way Ruby can be as simple as Python for manipulating a DLL ?

Thank you o/

4

2 に答える 2

2

RubyのFFIモジュールを試してください。

始めるための2つの例:

  1. 文字列へのポインタを返すDLLからC関数を呼び出す

  2. Ruby内からWin32関数を呼び出す

古いDLモジュールはあまり使用されおらず、それほど簡単ではないようです。

于 2013-01-06T13:58:29.117 に答える
0

dl標準ライブラリのモジュールを見てください。見事に文書化されていませんが、そこにある例は正しい方向を示しているはずです。

Rubyには以前Win32APIはWindowsで使用するモジュールがありましたが、現在は非推奨になっているため、直接使用する必要がありますdl

于 2012-11-07T16:55:04.437 に答える