Module: FFI

Extended by:
Library
Defined in:
lib/win32/windows/helper.rb

Class Method Summary collapse

Methods included from Library

attach_pfunc

Class Method Details

.raise_windows_error(function, err = FFI.errno) ⇒ Object

Raises:

  • (SystemCallError)


35
36
37
# File 'lib/win32/windows/helper.rb', line 35

def raise_windows_error(function, err=FFI.errno)
  raise SystemCallError.new(win_error(function, err), err)
end

.win_error(function, err = FFI.errno) ⇒ Object



26
27
28
29
30
31
32
33
# File 'lib/win32/windows/helper.rb', line 26

def win_error(function, err=FFI.errno)
  flags = 0x00001000 | 0x00000200
  buf = FFI::MemoryPointer.new(:char, 1024)

  FormatMessage(flags, nil, err , 0x0409, buf, 1024, nil)

  function + ': ' + buf.read_string.strip
end