Module: Puppet::Util::Windows::COM::Helpers
- Defined in:
- lib/puppet/util/windows/com.rb
Instance Method Summary collapse
Instance Method Details
#QueryInstance(klass) ⇒ Object
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/puppet/util/windows/com.rb', line 95 def QueryInstance(klass) instance = nil FFI::MemoryPointer.new(:pointer) do |ppv| QueryInterface(klass::IID, ppv) instance = klass.new(ppv.read_pointer) end begin yield instance return self ensure instance.Release end if block_given? instance end |
#UseInstance(klass, name, *args) ⇒ Object
114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/puppet/util/windows/com.rb', line 114 def UseInstance(klass, name, *args) instance = nil FFI::MemoryPointer.new(:pointer) do |ppv| send(name, *args, ppv) yield instance = klass.new(ppv.read_pointer) end self ensure instance.Release if instance && !instance.null? end |