summaryrefslogtreecommitdiff
path: root/ext/dl/lib/dl/win32.rb
blob: b507be5fde2a4ddf756c6af30830df6ca72f81ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# -*- ruby -*-

require 'dl'

class Win32API
  LIBRARY = {}

  attr_reader :val, :args

  def initialize(lib, func, args, ret)
    LIBRARY[lib] ||= DL.dlopen(lib)
    ty = (ret + args).tr('V','0')
    @sym = LIBRARY[lib].sym(func, ty)
    @__dll__ = LIBRARY[lib].to_i
    @__dllname__ = lib
    @__proc__ = @sym.to_i
    @val = nil
    @args = []
  end

  def call(*args)
    @val,@args = @sym.call(*args)
    return @val
  end
  alias Call call
end