source: extensions/gsdl-video/trunk/installed/cmdline/lib/ruby/1.8/dl/win32.rb@ 18425

Last change on this file since 18425 was 18425, checked in by davidb, 15 years ago

Video extension to Greenstone

File size: 564 bytes
Line 
1# -*- ruby -*-
2
3require 'dl'
4
5class Win32API
6 DLL = {}
7
8 def initialize(dllname, func, import, export = "0")
9 prototype = (export + import.to_s).tr("VPpNnLlIi", "0SSI")
10 handle = DLL[dllname] ||= DL::Handle.new(dllname)
11 @sym = handle.sym(func, prototype)
12 end
13
14 def call(*args)
15 import = @sym.proto.split("", 2)[1]
16 args.each_with_index do |x, i|
17 args[i] = nil if x == 0 and import[i] == ?S
18 args[i], = [x].pack("I").unpack("i") if import[i] == ?I
19 end
20 ret, = @sym.call(*args)
21 return ret || 0
22 end
23
24 alias Call call
25end
Note: See TracBrowser for help on using the repository browser.