module Win32::Registry::API

Win32 APIs

Win32 APIs

Public Instance Methods

CloseKey(hkey) click to toggle source
# File ext/dl/win32/lib/win32/registry.rb, line 306
def CloseKey(hkey)
  check RegCloseKey.call(hkey)
end
CreateKey(hkey, name, opt, desired) click to toggle source
# File ext/dl/win32/lib/win32/registry.rb, line 258
def CreateKey(hkey, name, opt, desired)
  result = packdw(0)
  disp = packdw(0)
  check RegCreateKeyExA.call(hkey, name, 0, 0, opt, desired,
                             0, result, disp)
  [ unpackdw(result), unpackdw(disp) ]
end
DeleteKey(hkey, name) click to toggle source
# File ext/dl/win32/lib/win32/registry.rb, line 298
def DeleteKey(hkey, name)
  check RegDeleteKey.call(hkey, name)
end
DeleteValue(hkey, name) click to toggle source
# File ext/dl/win32/lib/win32/registry.rb, line 294
def DeleteValue(hkey, name)
  check RegDeleteValue.call(hkey, name)
end
EnumKey(hkey, index) click to toggle source
# File ext/dl/win32/lib/win32/registry.rb, line 273
def EnumKey(hkey, index)
  name = ' ' * Constants::MAX_KEY_LENGTH
  size = packdw(Constants::MAX_KEY_LENGTH)
  wtime = ' ' * 8
  check RegEnumKeyExA.call(hkey, index, name, size, 0, 0, 0, wtime)
  [ name[0, unpackdw(size)], unpackqw(wtime) ]
end
EnumValue(hkey, index) click to toggle source
# File ext/dl/win32/lib/win32/registry.rb, line 266
def EnumValue(hkey, index)
  name = ' ' * Constants::MAX_KEY_LENGTH
  size = packdw(Constants::MAX_KEY_LENGTH)
  check RegEnumValueA.call(hkey, index, name, size, 0, 0, 0, 0)
  name[0, unpackdw(size)]
end
FlushKey(hkey) click to toggle source
# File ext/dl/win32/lib/win32/registry.rb, line 302
def FlushKey(hkey)
  check RegFlushKey.call(hkey)
end
OpenKey(hkey, name, opt, desired) click to toggle source
# File ext/dl/win32/lib/win32/registry.rb, line 252
def OpenKey(hkey, name, opt, desired)
  result = packdw(0)
  check RegOpenKeyExA.call(hkey, name, opt, desired, result)
  unpackdw(result)
end
QueryInfoKey(hkey) click to toggle source
# File ext/dl/win32/lib/win32/registry.rb, line 310
def QueryInfoKey(hkey)
  subkeys = packdw(0)
  maxsubkeylen = packdw(0)
  values = packdw(0)
  maxvaluenamelen = packdw(0)
  maxvaluelen = packdw(0)
  secdescs = packdw(0)
  wtime = ' ' * 8
  check RegQueryInfoKey.call(hkey, 0, 0, 0, subkeys, maxsubkeylen, 0,
    values, maxvaluenamelen, maxvaluelen, secdescs, wtime)
  [ unpackdw(subkeys), unpackdw(maxsubkeylen), unpackdw(values),
    unpackdw(maxvaluenamelen), unpackdw(maxvaluelen),
    unpackdw(secdescs), unpackqw(wtime) ]
end
QueryValue(hkey, name) click to toggle source
# File ext/dl/win32/lib/win32/registry.rb, line 281
def QueryValue(hkey, name)
  type = packdw(0)
  size = packdw(0)
  check RegQueryValueExA.call(hkey, name, 0, type, 0, size)
  data = ' ' * unpackdw(size)
  check RegQueryValueExA.call(hkey, name, 0, type, data, size)
  [ unpackdw(type), data[0, unpackdw(size)] ]
end
SetValue(hkey, name, type, data, size) click to toggle source
# File ext/dl/win32/lib/win32/registry.rb, line 290
def SetValue(hkey, name, type, data, size)
  check RegSetValueExA.call(hkey, name, 0, type, data, size)
end
check(result) click to toggle source
# File ext/dl/win32/lib/win32/registry.rb, line 230
def check(result)
  raise Error, result, caller(2) if result != 0
end
packdw(dw) click to toggle source
# File ext/dl/win32/lib/win32/registry.rb, line 234
def packdw(dw)
  [dw].pack('V')
end
packqw(qw) click to toggle source
# File ext/dl/win32/lib/win32/registry.rb, line 243
def packqw(qw)
  [ qw & 0xFFFFFFFF, qw >> 32 ].pack('VV')
end
unpackdw(dw) click to toggle source
# File ext/dl/win32/lib/win32/registry.rb, line 238
def unpackdw(dw)
  dw += [0].pack('V')
  dw.unpack('V')[0]
end
unpackqw(qw) click to toggle source
# File ext/dl/win32/lib/win32/registry.rb, line 247
def unpackqw(qw)
  qw = qw.unpack('VV')
  (qw[1] << 32) | qw[0]
end