Class: Win32API
- Inherits:
-
Object
- Object
- Win32API
- Defined in:
- lib/dl/win32.rb
Constant Summary collapse
- DLL =
{}
Instance Method Summary collapse
- #call(*args) ⇒ Object (also: #Call)
-
#initialize(dllname, func, import, export = "0") ⇒ Win32API
constructor
A new instance of Win32API.
Constructor Details
#initialize(dllname, func, import, export = "0") ⇒ Win32API
Returns a new instance of Win32API.
8 9 10 11 12 |
# File 'lib/dl/win32.rb', line 8 def initialize(dllname, func, import, export = "0") prototype = (export + import.to_s).tr("VPpNnLlIi", "0SSI").sub(/^(.)0*$/, '\1') handle = DLL[dllname] ||= DL::Handle.new(dllname) @sym = handle.sym(func, prototype) end |
Instance Method Details
#call(*args) ⇒ Object Also known as: Call
14 15 16 17 18 19 20 21 22 |
# File 'lib/dl/win32.rb', line 14 def call(*args) import = @sym.proto.split("", 2)[1] args.each_with_index do |x, i| args[i] = nil if x == 0 and import[i] == ?S args[i], = [x].pack("I").unpack("i") if import[i] == ?I end ret, = @sym.call(*args) return ret || 0 end |