Module: Win32::Registry::API
- Defined in:
- lib/win32/registry.rb
Overview
Win32 APIs
Instance Method Summary collapse
- #check(result) ⇒ Object
- #CloseKey(hkey) ⇒ Object
- #CreateKey(hkey, name, opt, desired) ⇒ Object
- #DeleteKey(hkey, name) ⇒ Object
- #DeleteValue(hkey, name) ⇒ Object
- #EnumKey(hkey, index) ⇒ Object
- #EnumValue(hkey, index) ⇒ Object
- #FlushKey(hkey) ⇒ Object
- #OpenKey(hkey, name, opt, desired) ⇒ Object
- #packdw(dw) ⇒ Object
- #packqw(qw) ⇒ Object
- #QueryInfoKey(hkey) ⇒ Object
- #QueryValue(hkey, name) ⇒ Object
- #SetValue(hkey, name, type, data, size) ⇒ Object
- #unpackdw(dw) ⇒ Object
- #unpackqw(qw) ⇒ Object
Instance Method Details
#check(result) ⇒ Object
396 397 398 |
# File 'lib/win32/registry.rb', line 396 def check(result) raise Error, result, caller(2) if result != 0 end |
#CloseKey(hkey) ⇒ Object
472 473 474 |
# File 'lib/win32/registry.rb', line 472 def CloseKey(hkey) check RegCloseKey.call(hkey) end |
#CreateKey(hkey, name, opt, desired) ⇒ Object
424 425 426 427 428 429 430 |
# File 'lib/win32/registry.rb', line 424 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) ⇒ Object
464 465 466 |
# File 'lib/win32/registry.rb', line 464 def DeleteKey(hkey, name) check RegDeleteKey.call(hkey, name) end |
#DeleteValue(hkey, name) ⇒ Object
460 461 462 |
# File 'lib/win32/registry.rb', line 460 def DeleteValue(hkey, name) check RegDeleteValue.call(hkey, name) end |
#EnumKey(hkey, index) ⇒ Object
439 440 441 442 443 444 445 |
# File 'lib/win32/registry.rb', line 439 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) ⇒ Object
432 433 434 435 436 437 |
# File 'lib/win32/registry.rb', line 432 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) ⇒ Object
468 469 470 |
# File 'lib/win32/registry.rb', line 468 def FlushKey(hkey) check RegFlushKey.call(hkey) end |
#OpenKey(hkey, name, opt, desired) ⇒ Object
418 419 420 421 422 |
# File 'lib/win32/registry.rb', line 418 def OpenKey(hkey, name, opt, desired) result = packdw(0) check RegOpenKeyExA.call(hkey, name, opt, desired, result) unpackdw(result) end |
#packdw(dw) ⇒ Object
400 401 402 |
# File 'lib/win32/registry.rb', line 400 def packdw(dw) [dw].pack('V') end |
#packqw(qw) ⇒ Object
409 410 411 |
# File 'lib/win32/registry.rb', line 409 def packqw(qw) [ qw & 0xFFFFFFFF, qw >> 32 ].pack('VV') end |
#QueryInfoKey(hkey) ⇒ Object
476 477 478 479 480 481 482 483 484 485 486 487 488 489 |
# File 'lib/win32/registry.rb', line 476 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) ⇒ Object
447 448 449 450 451 452 453 454 |
# File 'lib/win32/registry.rb', line 447 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) ⇒ Object
456 457 458 |
# File 'lib/win32/registry.rb', line 456 def SetValue(hkey, name, type, data, size) check RegSetValueExA.call(hkey, name, 0, type, data, size) end |
#unpackdw(dw) ⇒ Object
404 405 406 407 |
# File 'lib/win32/registry.rb', line 404 def unpackdw(dw) dw += [0].pack('V') dw.unpack('V')[0] end |
#unpackqw(qw) ⇒ Object
413 414 415 416 |
# File 'lib/win32/registry.rb', line 413 def unpackqw(qw) qw = qw.unpack('VV') (qw[1] << 32) | qw[0] end |