class NPGRT::Win32API::API
Public Class Methods
new(dll, func, param = nil, ret = "L")
click to toggle source
# File lib/npgrt/win32api.rb, line 7 def initialize(dll, func, param = nil, ret = "L") @dll, @func, @param, @ret = dll, func, param, ret end
Public Instance Methods
call(*args)
click to toggle source
# File lib/npgrt/win32api.rb, line 27 def call(*args) param = @param || guess(args) @api ||= findapi(@dll, @func, param, @ret) @api.call(*args) end
findapi(dll, func, param, ret)
click to toggle source
# File lib/npgrt/win32api.rb, line 11 def findapi(dll, func, param, ret) [dll, File.basename(dll) + "_" + NPGRT::PlatformWidth.to_s + File.extname(dll)].each{|d| [func, func + "A", func + "W"].each{|f| if (a = begin W.new(d, f, param, ret) rescue LoadError, RuntimeError nil end ) return a end } } raise Errno::ENOENT, " NPGRT::API: Can't find a proper DLL for #{dll}!#{func}" end
guess(args)
click to toggle source
# File lib/npgrt/win32api.rb, line 37 def guess(args) args.map{|x| Integer === x ? "L" : "p"} end
inspect()
click to toggle source
# File lib/npgrt/win32api.rb, line 33 def inspect "#<API #{@dll}!#{@func} takes #{@param || '<auto>'} returns #{@ret}>" end