class MiniTerm::Win32API
The classic Win32API
gem is deprecated, so we emulate it with fiddle.
Constants
- DLL
- TYPES
Public Class Methods
new(dll_name, func, import, export = "0", _ct = nil)
click to toggle source
# File lib/mini_term/windows/win_32_api.rb, line 16 def initialize(dll_name, func, import, export = "0", _ct = nil) @proto = import.join.tr("VPpNnLlIi", "0SSI").chomp('0').split('') handle = DLL[dll_name] ||= Fiddle.dlopen(dll_name) @func = Fiddle::Function.new(handle[func], TYPES.values_at(*@proto), 1) end
Public Instance Methods
call(*args)
click to toggle source
# File lib/mini_term/windows/win_32_api.rb, line 22 def call(*args) args.each_with_index do |x, i| if @proto[i] == "S" args[i] = [x == 0 ? nil : x].pack("p").unpack("l!*")[0] end end @func.call(*args).to_i end