Module: Puppet::Util::Windows::COM

Extended by:
FFI::Library
Defined in:
lib/puppet/util/windows/com.rb

Defined Under Namespace

Modules: Factory, Helpers, Instance, Interface

Constant Summary collapse

S_OK =
0
S_FALSE =
1
CLSCTX_INPROC_SERVER =
0x1
CLSCTX_INPROC_HANDLER =
0x2
CLSCTX_LOCAL_SERVER =
0x4
CLSCTX_INPROC_SERVER16 =
0x8
CLSCTX_REMOTE_SERVER =
0x10
CLSCTX_INPROC_HANDLER16 =
0x20
CLSCTX_RESERVED1 =
0x40
CLSCTX_RESERVED2 =
0x80
CLSCTX_RESERVED3 =
0x100
CLSCTX_RESERVED4 =
0x200
CLSCTX_NO_CODE_DOWNLOAD =
0x400
CLSCTX_RESERVED5 =
0x800
CLSCTX_NO_CUSTOM_MARSHAL =
0x1000
CLSCTX_ENABLE_CODE_DOWNLOAD =
0x2000
CLSCTX_NO_FAILURE_LOG =
0x4000
CLSCTX_DISABLE_AAA =
0x8000
CLSCTX_ENABLE_AAA =
0x10000
CLSCTX_FROM_DEFAULT_CONTEXT =
0x20000
CLSCTX_ACTIVATE_32_BIT_SERVER =
0x40000
CLSCTX_ACTIVATE_64_BIT_SERVER =
0x80000
CLSCTX_ENABLE_CLOAKING =
0x100000
CLSCTX_PS_DLL =
-0x80000000
CLSCTX_INPROC =
CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER
CLSCTX_ALL =
CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER | CLSCTX_LOCAL_SERVER | CLSCTX_REMOTE_SERVER
CLSCTX_SERVER =
CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER | CLSCTX_REMOTE_SERVER
IUnknown =
Unknown =

Class Method Summary collapse

Class Method Details

.FAILED(hr) ⇒ Object



14
# File 'lib/puppet/util/windows/com.rb', line 14

def FAILED(hr) hr < 0 end

.InitializeComObject



221
222
223
224
225
# File 'lib/puppet/util/windows/com.rb', line 221

def InitializeCom
  raise_if_hresult_failed(:CoInitialize, FFI::Pointer::NULL)

  at_exit { CoUninitialize() }
end

.raise_if_hresult_failed(name, *args) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/puppet/util/windows/com.rb', line 18

def raise_if_hresult_failed(name, *args)
  failed = FAILED(result = send(name, *args)) and raise _("%{name} failed (hresult %{result}).") % { name: name, result: format('%#08x', result) }

  result
ensure
  yield failed if block_given?
end

.SUCCEEDED(hr) ⇒ Object



13
# File 'lib/puppet/util/windows/com.rb', line 13

def SUCCEEDED(hr) hr >= 0 end