Module: Puppet::Util::Windows::COM::Helpers Private

Defined in:
lib/puppet/util/windows/com.rb

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Instance Method Details

#QueryInstance(klass) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/puppet/util/windows/com.rb', line 93

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

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/puppet/util/windows/com.rb', line 112

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