# module Win32::Registry::API

`Win32` APIs

### Constants

TEMPLATE_DWORD
TEMPLATE_HANDLE
TEMPLATE_QWORD

### Public Instance Methods

CloseKey (hkey)
Source

    # File ext/win32/lib/win32/registry.rb, line 351
    def CloseKey(hkey)
      check RegCloseKey.call(hkey)
    end

CreateKey (hkey, name, opt, desired)
Source

    # File ext/win32/lib/win32/registry.rb, line 297
    def CreateKey(hkey, name, opt, desired)
      result = packhandle(0)
      disp = packdw(0)
      check RegCreateKeyExW.call(hkey, make_wstr(name), 0, 0, opt, desired,
                                 nil, result, disp)
      [ unpackhandle(result), unpackdw(disp) ]
    end

DeleteKey (hkey, name)
Source

    # File ext/win32/lib/win32/registry.rb, line 343
    def DeleteKey(hkey, name)
      check RegDeleteKeyW.call(hkey, make_wstr(name))
    end

DeleteValue (hkey, name)
Source

    # File ext/win32/lib/win32/registry.rb, line 339
    def DeleteValue(hkey, name)
      check RegDeleteValueW.call(hkey, make_wstr(name))
    end

EnumKey (hkey, index)
Source

    # File ext/win32/lib/win32/registry.rb, line 312
    def EnumKey(hkey, index)
      name = WCHAR_NUL * Constants::MAX_KEY_LENGTH
      size = packdw(Constants::MAX_KEY_LENGTH)
      wtime = ' ' * 8
      check RegEnumKeyExW.call(hkey, index, name, size, nil, nil, nil, wtime)
      [ name.byteslice(0, unpackdw(size) * WCHAR_SIZE), unpackqw(wtime) ]
    end

EnumValue (hkey, index)
Source

    # File ext/win32/lib/win32/registry.rb, line 305
    def EnumValue(hkey, index)
      name = WCHAR_NUL * Constants::MAX_KEY_LENGTH
      size = packdw(Constants::MAX_KEY_LENGTH)
      check RegEnumValueW.call(hkey, index, name, size, nil, nil, nil, nil)
      name.byteslice(0, unpackdw(size) * WCHAR_SIZE)
    end

FlushKey (hkey)
Source

    # File ext/win32/lib/win32/registry.rb, line 347
    def FlushKey(hkey)
      check RegFlushKey.call(hkey)
    end

OpenKey (hkey, name, opt, desired)
Source

    # File ext/win32/lib/win32/registry.rb, line 291
    def OpenKey(hkey, name, opt, desired)
      result = packhandle(0)
      check RegOpenKeyExW.call(hkey, make_wstr(name), opt, desired, result)
      unpackhandle(result)
    end

QueryInfoKey (hkey)
Source

    # File ext/win32/lib/win32/registry.rb, line 355
    def QueryInfoKey(hkey)
      subkeys = packdw(0)
      maxsubkeylen = packdw(0)
      values = packdw(0)
      maxvaluenamelen = packdw(0)
      maxvaluelen = packdw(0)
      secdescs = packdw(0)
      wtime = ' ' * 8
      check RegQueryInfoKeyW.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)
Source

    # File ext/win32/lib/win32/registry.rb, line 320
    def QueryValue(hkey, name)
      type = packdw(0)
      size = packdw(0)
      name = make_wstr(name)
      check RegQueryValueExW.call(hkey, name, nil, type, nil, size)
      data = "\0".b * unpackdw(size)
      check RegQueryValueExW.call(hkey, name, nil, type, data, size)
      [ unpackdw(type), data[0, unpackdw(size)] ]
    end

SetValue (hkey, name, type, data, size)
Source

    # File ext/win32/lib/win32/registry.rb, line 330
    def SetValue(hkey, name, type, data, size)
      case type
      when REG_SZ, REG_EXPAND_SZ, REG_MULTI_SZ
        data = data.encode(WCHAR)
        size ||= data.bytesize + WCHAR_SIZE
      end
      check RegSetValueExW.call(hkey, make_wstr(name), 0, type, data, size)
    end

check (result)
Source

    # File ext/win32/lib/win32/registry.rb, line 249
    def check(result)
      raise Error, result, caller(1) if result != 0
    end

make_wstr (str)
Source

    # File ext/win32/lib/win32/registry.rb, line 287
    def make_wstr(str)
      (str+"\0").encode(WCHAR)
    end

packdw (dw)
Source

    # File ext/win32/lib/win32/registry.rb, line 269
    def packdw(dw)
      [dw].pack(TEMPLATE_DWORD)
    end

packhandle (h)
Source

    # File ext/win32/lib/win32/registry.rb, line 259
    def packhandle(h)
      [h].pack(TEMPLATE_HANDLE)
    end

packqw (qw)
Source

    # File ext/win32/lib/win32/registry.rb, line 279
    def packqw(qw)
      [qw].pack(TEMPLATE_QWORD)
    end

unpackdw (dw)
Source

    # File ext/win32/lib/win32/registry.rb, line 273
    def unpackdw(dw)
      (dw + [0].pack(TEMPLATE_DWORD)).unpack1(TEMPLATE_DWORD)
    end

unpackhandle (h)
Source

    # File ext/win32/lib/win32/registry.rb, line 263
    def unpackhandle(h)
      (h + [0].pack(TEMPLATE_HANDLE)).unpack1(TEMPLATE_HANDLE)
    end

unpackqw (qw)
Source

    # File ext/win32/lib/win32/registry.rb, line 283
    def unpackqw(qw)
      (qw + [0].pack(TEMPLATE_QWORD)).unpack1(TEMPLATE_QWORD)
    end

win64? ()
Source

    # File ext/win32/lib/win32/registry.rb, line 253
    def win64?
      /^(?:x64|x86_64)/ =~ RUBY_PLATFORM
    end