module Unknownr::Windows::COM::Factory
Public Class Methods
[](iface, clsid)
click to toggle source
# File lib/unknownr.rb, line 183 def self.[](iface, clsid) Class.new(iface) { send(:include, Helpers) const_set(:CLSID, clsid) def initialize(opts = {}) @opts = opts @opts[:clsctx] ||= CLSCTX_INPROC_SERVER FFI::MemoryPointer.new(:pointer) { |ppv| raise "CoCreateInstance failed (#{self.class})." if Windows.FAILED(Windows.CoCreateInstance(self.class::CLSID, nil, @opts[:clsctx], self.class::IID, ppv)) self.pointer = ppv.read_pointer } @vtbl = self.class::VTBL.new(self[:lpVtbl]) end attr_reader :vtbl self::VTBL.members.each { |name| define_method(name) { |*args| raise "#{self}.#{name} failed." if Windows.FAILED(result = @vtbl[name].call(self, *args)); result } } } end
new(opts = {})
click to toggle source
# File lib/unknownr.rb, line 189 def initialize(opts = {}) @opts = opts @opts[:clsctx] ||= CLSCTX_INPROC_SERVER FFI::MemoryPointer.new(:pointer) { |ppv| raise "CoCreateInstance failed (#{self.class})." if Windows.FAILED(Windows.CoCreateInstance(self.class::CLSID, nil, @opts[:clsctx], self.class::IID, ppv)) self.pointer = ppv.read_pointer } @vtbl = self.class::VTBL.new(self[:lpVtbl]) end