win32-registry 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.document +5 -0
- data/.rdoc_options +3 -0
- data/docs/win32.rb +3 -0
- data/lib/win32/registry.rb +134 -117
- data/win32-registry.gemspec +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: dff9a41b01f54813d117b31fedb59508f7064f32b3df2996cb2659b3e3a3a93e
|
|
4
|
+
data.tar.gz: ff5bb76df05d7bd6b65b6d527f42ec35dd42f86a12cb44def7b5245ea94ba081
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9ea233da77c02e4d5af6e9c146873fde34ce70892dc86fad65006504f987583f9dff50bc618613b343040ddb7701041e66dad1a7f879bc6a456da6b186c4ef9c
|
|
7
|
+
data.tar.gz: 146fb98cfbfca01fee34c48c35210590dfdc29b11220a255ce482af2425cd27557e12023abab8a4a4358d1e95be4f457355d4af91828805726a774e23a0854e4
|
data/.rdoc_options
ADDED
data/docs/win32.rb
ADDED
data/lib/win32/registry.rb
CHANGED
|
@@ -2,83 +2,74 @@
|
|
|
2
2
|
require 'fiddle/import'
|
|
3
3
|
|
|
4
4
|
module Win32
|
|
5
|
-
|
|
6
|
-
=begin rdoc
|
|
7
|
-
= Win32 Registry
|
|
8
|
-
|
|
9
|
-
win32/registry is registry accessor library for Win32 platform.
|
|
10
|
-
It uses importer to call Win32 Registry APIs.
|
|
11
|
-
|
|
12
|
-
== example
|
|
13
|
-
Win32::Registry::HKEY_CURRENT_USER.open('SOFTWARE\foo') do |reg|
|
|
14
|
-
value = reg['foo'] # read a value
|
|
15
|
-
value = reg['foo', Win32::Registry::REG_SZ] # read a value with type
|
|
16
|
-
type, value = reg.read('foo') # read a value
|
|
17
|
-
reg['foo'] = 'bar' # write a value
|
|
18
|
-
reg['foo', Win32::Registry::REG_SZ] = 'bar' # write a value with type
|
|
19
|
-
reg.write('foo', Win32::Registry::REG_SZ, 'bar') # write a value
|
|
20
|
-
|
|
21
|
-
reg.each_value { |name, type, data| ... } # Enumerate values
|
|
22
|
-
reg.each_key { |key, wtime| ... } # Enumerate subkeys
|
|
23
|
-
|
|
24
|
-
reg.delete_value(name) # Delete a value
|
|
25
|
-
reg.delete_key(name) # Delete a subkey
|
|
26
|
-
reg.delete_key(name, true) # Delete a subkey recursively
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
= Reference
|
|
30
|
-
|
|
31
|
-
== Win32::Registry class
|
|
32
|
-
|
|
33
|
-
--- info
|
|
34
|
-
|
|
35
|
-
--- num_keys
|
|
36
|
-
|
|
37
|
-
--- max_key_length
|
|
38
|
-
|
|
39
|
-
--- num_values
|
|
40
|
-
|
|
41
|
-
--- max_value_name_length
|
|
42
|
-
|
|
43
|
-
--- max_value_length
|
|
44
|
-
|
|
45
|
-
--- descriptor_length
|
|
46
|
-
|
|
47
|
-
--- wtime
|
|
48
|
-
Returns an item of key information.
|
|
49
|
-
|
|
50
|
-
=== constants
|
|
51
|
-
--- HKEY_CLASSES_ROOT
|
|
52
|
-
|
|
53
|
-
--- HKEY_CURRENT_USER
|
|
54
|
-
|
|
55
|
-
--- HKEY_LOCAL_MACHINE
|
|
56
|
-
|
|
57
|
-
--- HKEY_PERFORMANCE_DATA
|
|
58
|
-
|
|
59
|
-
--- HKEY_CURRENT_CONFIG
|
|
60
|
-
|
|
61
|
-
--- HKEY_DYN_DATA
|
|
62
|
-
|
|
63
|
-
Win32::Registry object whose key is predefined key.
|
|
64
|
-
For detail, see the MSDN[http://msdn.microsoft.com/library/en-us/sysinfo/base/predefined_keys.asp] article.
|
|
65
|
-
|
|
66
|
-
=end rdoc
|
|
67
|
-
|
|
5
|
+
# :stopdoc:
|
|
68
6
|
WCHAR = Encoding::UTF_16LE
|
|
69
7
|
WCHAR_NUL = "\0".encode(WCHAR).freeze
|
|
70
8
|
WCHAR_CR = "\r".encode(WCHAR).freeze
|
|
71
9
|
WCHAR_SIZE = WCHAR_NUL.bytesize
|
|
72
10
|
LOCALE = Encoding::UTF_8
|
|
73
11
|
|
|
12
|
+
# :startdoc:
|
|
13
|
+
|
|
14
|
+
# win32/registry is registry accessor library for Win32 platform.
|
|
15
|
+
# It uses importer to call Win32 Registry APIs.
|
|
16
|
+
#
|
|
17
|
+
# == example
|
|
18
|
+
# Win32::Registry::HKEY_CURRENT_USER.open('SOFTWARE\foo') do |reg|
|
|
19
|
+
# value = reg['foo'] # read a value
|
|
20
|
+
# value = reg['foo', Win32::Registry::REG_SZ] # read a value with type
|
|
21
|
+
# type, value = reg.read('foo') # read a value
|
|
22
|
+
# reg['foo'] = 'bar' # write a value
|
|
23
|
+
# reg['foo', Win32::Registry::REG_SZ] = 'bar' # write a value with type
|
|
24
|
+
# reg.write('foo', Win32::Registry::REG_SZ, 'bar') # write a value
|
|
25
|
+
#
|
|
26
|
+
# reg.each_value { |name, type, data| ... } # Enumerate values
|
|
27
|
+
# reg.each_key { |key, wtime| ... } # Enumerate subkeys
|
|
28
|
+
#
|
|
29
|
+
# reg.delete_value(name) # Delete a value
|
|
30
|
+
# reg.delete_key(name) # Delete a subkey
|
|
31
|
+
# reg.delete_key(name, true) # Delete a subkey recursively
|
|
32
|
+
# end
|
|
33
|
+
#
|
|
34
|
+
# == Predefined keys
|
|
35
|
+
#
|
|
36
|
+
# * +HKEY_CLASSES_ROOT+
|
|
37
|
+
# * +HKEY_CURRENT_USER+
|
|
38
|
+
# * +HKEY_LOCAL_MACHINE+
|
|
39
|
+
# * +HKEY_PERFORMANCE_DATA+
|
|
40
|
+
# * +HKEY_CURRENT_CONFIG+
|
|
41
|
+
# * +HKEY_DYN_DATA+
|
|
42
|
+
#
|
|
43
|
+
# Win32::Registry object whose key is predefined key.
|
|
44
|
+
# For detail, see the article[https://learn.microsoft.com/en-us/windows/win32/sysinfo/predefined-keys].
|
|
45
|
+
#
|
|
46
|
+
# == Value types
|
|
47
|
+
#
|
|
48
|
+
# * +REG_NONE+
|
|
49
|
+
# * +REG_SZ+
|
|
50
|
+
# * +REG_EXPAND_SZ+
|
|
51
|
+
# * +REG_BINARY+
|
|
52
|
+
# * +REG_DWORD+
|
|
53
|
+
# * +REG_DWORD_BIG_ENDIAN+
|
|
54
|
+
# * +REG_LINK+
|
|
55
|
+
# * +REG_MULTI_SZ+
|
|
56
|
+
# * +REG_RESOURCE_LIST+
|
|
57
|
+
# * +REG_FULL_RESOURCE_DESCRIPTOR+
|
|
58
|
+
# * +REG_RESOURCE_REQUIREMENTS_LIST+
|
|
59
|
+
# * +REG_QWORD+
|
|
60
|
+
#
|
|
61
|
+
# For detail, see the article[https://learn.microsoft.com/en-us/windows/win32/sysinfo/registry-value-types].
|
|
62
|
+
#
|
|
74
63
|
class Registry
|
|
75
64
|
|
|
65
|
+
# :stopdoc:
|
|
66
|
+
|
|
76
67
|
#
|
|
77
68
|
# For detail, see the MSDN[http://msdn.microsoft.com/library/en-us/sysinfo/base/registry.asp].
|
|
78
69
|
#
|
|
79
70
|
# --- HKEY_*
|
|
80
71
|
#
|
|
81
|
-
# Predefined key
|
|
72
|
+
# Predefined key *handle*.
|
|
82
73
|
# These are Integer, not Win32::Registry.
|
|
83
74
|
#
|
|
84
75
|
# --- REG_*
|
|
@@ -100,6 +91,7 @@ For detail, see the MSDN[http://msdn.microsoft.com/library/en-us/sysinfo/base/pr
|
|
|
100
91
|
# If the key is created newly or opened existing key.
|
|
101
92
|
# See also Registry#disposition method.
|
|
102
93
|
module Constants
|
|
94
|
+
# :stopdoc:
|
|
103
95
|
HKEY_CLASSES_ROOT = 0x80000000
|
|
104
96
|
HKEY_CURRENT_USER = 0x80000001
|
|
105
97
|
HKEY_LOCAL_MACHINE = 0x80000002
|
|
@@ -115,7 +107,6 @@ For detail, see the MSDN[http://msdn.microsoft.com/library/en-us/sysinfo/base/pr
|
|
|
115
107
|
REG_EXPAND_SZ = 2
|
|
116
108
|
REG_BINARY = 3
|
|
117
109
|
REG_DWORD = 4
|
|
118
|
-
REG_DWORD_LITTLE_ENDIAN = 4
|
|
119
110
|
REG_DWORD_BIG_ENDIAN = 5
|
|
120
111
|
REG_LINK = 6
|
|
121
112
|
REG_MULTI_SZ = 7
|
|
@@ -163,16 +154,23 @@ For detail, see the MSDN[http://msdn.microsoft.com/library/en-us/sysinfo/base/pr
|
|
|
163
154
|
end
|
|
164
155
|
include Constants
|
|
165
156
|
include Enumerable
|
|
157
|
+
# :startdoc:
|
|
166
158
|
|
|
167
159
|
#
|
|
168
160
|
# Error
|
|
169
161
|
#
|
|
170
162
|
class Error < ::StandardError
|
|
163
|
+
# :stopdoc:
|
|
171
164
|
module Kernel32
|
|
172
165
|
extend Fiddle::Importer
|
|
173
166
|
dlload "kernel32.dll"
|
|
174
167
|
end
|
|
175
168
|
FormatMessageW = Kernel32.extern "int FormatMessageW(int, void *, int, int, void *, int, void *)", :stdcall
|
|
169
|
+
# :startdoc:
|
|
170
|
+
|
|
171
|
+
# new(code) -> error object
|
|
172
|
+
#
|
|
173
|
+
# Initializes the message for Win32 API error +code+.
|
|
176
174
|
def initialize(code)
|
|
177
175
|
@code = code
|
|
178
176
|
buff = WCHAR_NUL * 1024
|
|
@@ -190,6 +188,8 @@ For detail, see the MSDN[http://msdn.microsoft.com/library/en-us/sysinfo/base/pr
|
|
|
190
188
|
end
|
|
191
189
|
super msg
|
|
192
190
|
end
|
|
191
|
+
|
|
192
|
+
# Win32 API error code.
|
|
193
193
|
attr_reader :code
|
|
194
194
|
end
|
|
195
195
|
|
|
@@ -197,6 +197,7 @@ For detail, see the MSDN[http://msdn.microsoft.com/library/en-us/sysinfo/base/pr
|
|
|
197
197
|
# Predefined Keys
|
|
198
198
|
#
|
|
199
199
|
class PredefinedKey < Registry
|
|
200
|
+
# :stopdoc:
|
|
200
201
|
def initialize(hkey, keyname)
|
|
201
202
|
@hkey = Fiddle::Pointer.new(hkey)
|
|
202
203
|
@parent = nil
|
|
@@ -224,6 +225,7 @@ For detail, see the MSDN[http://msdn.microsoft.com/library/en-us/sysinfo/base/pr
|
|
|
224
225
|
# Win32 APIs
|
|
225
226
|
#
|
|
226
227
|
module API
|
|
228
|
+
# :stopdoc:
|
|
227
229
|
include Constants
|
|
228
230
|
extend Fiddle::Importer
|
|
229
231
|
dlload "advapi32.dll"
|
|
@@ -367,12 +369,14 @@ For detail, see the MSDN[http://msdn.microsoft.com/library/en-us/sysinfo/base/pr
|
|
|
367
369
|
unpackdw(secdescs), unpackqw(wtime) ]
|
|
368
370
|
end
|
|
369
371
|
end
|
|
372
|
+
# :startdoc:
|
|
370
373
|
|
|
371
374
|
#
|
|
372
|
-
# Replace
|
|
375
|
+
# Replace <tt>%</tt>-enclosed substrings in +str+ into the
|
|
376
|
+
# environment value of what is contained between the <tt>%</tt>s.
|
|
373
377
|
# This method is used for REG_EXPAND_SZ.
|
|
374
378
|
#
|
|
375
|
-
# For detail, see
|
|
379
|
+
# For detail, see ExpandEnvironmentStrings[https://learn.microsoft.com/en-us/windows/win32/api/processenv/nf-processenv-expandenvironmentstringsw] \Win32 \API.
|
|
376
380
|
#
|
|
377
381
|
def self.expand_environ(str)
|
|
378
382
|
str.gsub(Regexp.compile("%([^%]+)%".encode(str.encoding))) {
|
|
@@ -392,21 +396,21 @@ For detail, see the MSDN[http://msdn.microsoft.com/library/en-us/sysinfo/base/pr
|
|
|
392
396
|
end.freeze
|
|
393
397
|
|
|
394
398
|
#
|
|
395
|
-
# Convert registry type value to readable string.
|
|
399
|
+
# Convert registry type value +type+ to readable string.
|
|
396
400
|
#
|
|
397
401
|
def self.type2name(type)
|
|
398
402
|
@@type2name[type] || type.to_s
|
|
399
403
|
end
|
|
400
404
|
|
|
401
405
|
#
|
|
402
|
-
# Convert 64-bit FILETIME integer into Time object.
|
|
406
|
+
# Convert 64-bit FILETIME integer +wtime+ into Time object.
|
|
403
407
|
#
|
|
404
408
|
def self.wtime2time(wtime)
|
|
405
409
|
Time.at((wtime - 116444736000000000) / 10000000)
|
|
406
410
|
end
|
|
407
411
|
|
|
408
412
|
#
|
|
409
|
-
# Convert Time object or Integer object into 64-bit FILETIME.
|
|
413
|
+
# Convert Time object or Integer object +time+ into 64-bit FILETIME.
|
|
410
414
|
#
|
|
411
415
|
def self.time2wtime(time)
|
|
412
416
|
time.to_i * 10000000 + 116444736000000000
|
|
@@ -418,16 +422,19 @@ For detail, see the MSDN[http://msdn.microsoft.com/library/en-us/sysinfo/base/pr
|
|
|
418
422
|
private_class_method :new
|
|
419
423
|
|
|
420
424
|
#
|
|
421
|
-
#
|
|
425
|
+
# call-seq:
|
|
426
|
+
# open(key, subkey, desired = KEY_READ, opt = REG_OPTION_RESERVED)
|
|
427
|
+
# open(key, subkey, desired = KEY_READ, opt = REG_OPTION_RESERVED) { |reg| ... }
|
|
422
428
|
#
|
|
423
|
-
#
|
|
429
|
+
# Open the registry key +subkey+ under +key+.
|
|
430
|
+
# +key+ is Win32::Registry object of parent key.
|
|
431
|
+
# You can use {predefined key}[rdoc-ref:Win32::Registry@Predefined+keys] +HKEY_+*.
|
|
432
|
+
# +desired+ and +opt+ is access mask and key option.
|
|
424
433
|
#
|
|
425
|
-
# Open the registry key subkey under key.
|
|
426
|
-
# key is Win32::Registry object of parent key.
|
|
427
|
-
# You can use predefined key HKEY_* (see Constants)
|
|
428
|
-
# desired and opt is access mask and key option.
|
|
429
434
|
# For detail, see the MSDN[http://msdn.microsoft.com/library/en-us/sysinfo/base/regopenkeyex.asp].
|
|
430
|
-
#
|
|
435
|
+
#
|
|
436
|
+
# If block is given, the key +reg+ is yielded and closed
|
|
437
|
+
# automatically after the block exists.
|
|
431
438
|
def self.open(hkey, subkey, desired = KEY_READ, opt = REG_OPTION_RESERVED)
|
|
432
439
|
subkey = subkey.chomp('\\')
|
|
433
440
|
newkey = API.OpenKey(hkey.instance_variable_get(:@hkey), subkey, opt, desired)
|
|
@@ -444,17 +451,19 @@ For detail, see the MSDN[http://msdn.microsoft.com/library/en-us/sysinfo/base/pr
|
|
|
444
451
|
end
|
|
445
452
|
|
|
446
453
|
#
|
|
447
|
-
#
|
|
448
|
-
#
|
|
449
|
-
#
|
|
454
|
+
# call-seq:
|
|
455
|
+
# create(key, subkey, desired = KEY_ALL_ACCESS, opt = REG_OPTION_RESERVED)
|
|
456
|
+
# create(key, subkey, desired = KEY_ALL_ACCESS, opt = REG_OPTION_RESERVED) { |reg| ... }
|
|
450
457
|
#
|
|
451
|
-
# Create or open the registry key subkey under key
|
|
452
|
-
# You can use predefined key HKEY_
|
|
458
|
+
# Create or open the registry key +subkey+ under +key+.
|
|
459
|
+
# You can use {predefined key}[rdoc-ref:Win32::Registry@Predefined+keys] +HKEY_+*.
|
|
460
|
+
# +desired+ and +opt+ is access mask and key option.
|
|
453
461
|
#
|
|
454
|
-
# If subkey is already exists, key is opened and Registry#created?
|
|
462
|
+
# If +subkey+ is already exists, key is opened and Registry#created?
|
|
455
463
|
# method will return false.
|
|
456
464
|
#
|
|
457
|
-
# If block is given, the key is closed
|
|
465
|
+
# If block is given, the key +reg+ is yielded and closed
|
|
466
|
+
# automatically after the block exists.
|
|
458
467
|
#
|
|
459
468
|
def self.create(hkey, subkey, desired = KEY_ALL_ACCESS, opt = REG_OPTION_RESERVED)
|
|
460
469
|
newkey, disp = API.CreateKey(hkey.instance_variable_get(:@hkey), subkey, opt, desired)
|
|
@@ -476,7 +485,9 @@ For detail, see the MSDN[http://msdn.microsoft.com/library/en-us/sysinfo/base/pr
|
|
|
476
485
|
@@final = proc { |hkey| proc { API.CloseKey(hkey[0]) if hkey[0] } }
|
|
477
486
|
|
|
478
487
|
#
|
|
479
|
-
#
|
|
488
|
+
# :nodoc:
|
|
489
|
+
#
|
|
490
|
+
# Use self.open, self.create, #open and #create.
|
|
480
491
|
#
|
|
481
492
|
def initialize(hkey, parent, keyname, disposition)
|
|
482
493
|
@hkey = Fiddle::Pointer.new(hkey)
|
|
@@ -501,7 +512,7 @@ For detail, see the MSDN[http://msdn.microsoft.com/library/en-us/sysinfo/base/pr
|
|
|
501
512
|
end
|
|
502
513
|
|
|
503
514
|
#
|
|
504
|
-
# Returns if key is created
|
|
515
|
+
# Returns +true+ if key is created *newly*.
|
|
505
516
|
# (see Registry.create) -- basically you call create
|
|
506
517
|
# then when you call created? on the instance returned
|
|
507
518
|
# it will tell if it was successful or not
|
|
@@ -518,7 +529,7 @@ For detail, see the MSDN[http://msdn.microsoft.com/library/en-us/sysinfo/base/pr
|
|
|
518
529
|
end
|
|
519
530
|
|
|
520
531
|
#
|
|
521
|
-
# Full path of key such as 'HKEY_CURRENT_USER\SOFTWARE\foo\bar'
|
|
532
|
+
# Full path of key such as <tt>'HKEY_CURRENT_USER\SOFTWARE\foo\bar'</tt>.
|
|
522
533
|
#
|
|
523
534
|
def name
|
|
524
535
|
parent = self
|
|
@@ -529,6 +540,9 @@ For detail, see the MSDN[http://msdn.microsoft.com/library/en-us/sysinfo/base/pr
|
|
|
529
540
|
name
|
|
530
541
|
end
|
|
531
542
|
|
|
543
|
+
#
|
|
544
|
+
# Retruns inspected string
|
|
545
|
+
#
|
|
532
546
|
def inspect
|
|
533
547
|
"\#<Win32::Registry key=#{name.inspect}>"
|
|
534
548
|
end
|
|
@@ -541,14 +555,14 @@ For detail, see the MSDN[http://msdn.microsoft.com/library/en-us/sysinfo/base/pr
|
|
|
541
555
|
end
|
|
542
556
|
|
|
543
557
|
#
|
|
544
|
-
# Same as Win32::Registry.open
|
|
558
|
+
# Same as Win32::Registry.open(self, subkey, desired, opt)
|
|
545
559
|
#
|
|
546
560
|
def open(subkey, desired = KEY_READ, opt = REG_OPTION_RESERVED, &blk)
|
|
547
561
|
self.class.open(self, subkey, desired, opt, &blk)
|
|
548
562
|
end
|
|
549
563
|
|
|
550
564
|
#
|
|
551
|
-
# Same as Win32::Registry.create
|
|
565
|
+
# Same as Win32::Registry.create(self, subkey, desired, opt)
|
|
552
566
|
#
|
|
553
567
|
def create(subkey, desired = KEY_ALL_ACCESS, opt = REG_OPTION_RESERVED, &blk)
|
|
554
568
|
self.class.create(self, subkey, desired, opt, &blk)
|
|
@@ -571,7 +585,7 @@ For detail, see the MSDN[http://msdn.microsoft.com/library/en-us/sysinfo/base/pr
|
|
|
571
585
|
# For each value it yields key, type and data.
|
|
572
586
|
#
|
|
573
587
|
# key is a String which contains name of key.
|
|
574
|
-
# type is a type constant kind of Win32::Registry::REG_
|
|
588
|
+
# type is a type constant kind of +Win32::Registry::REG_+*
|
|
575
589
|
# data is the value of this key.
|
|
576
590
|
#
|
|
577
591
|
def each_value
|
|
@@ -640,21 +654,23 @@ For detail, see the MSDN[http://msdn.microsoft.com/library/en-us/sysinfo/base/pr
|
|
|
640
654
|
end
|
|
641
655
|
|
|
642
656
|
# Read a registry value named name and return array of
|
|
643
|
-
# [ type, data ]
|
|
644
|
-
# When name is nil
|
|
645
|
-
#
|
|
646
|
-
#
|
|
647
|
-
#
|
|
657
|
+
# <tt>[ type, data ]</tt>.
|
|
658
|
+
# When name is +nil+, the `default' value is read.
|
|
659
|
+
#
|
|
660
|
+
# +type+ is {value type}[rdoc-ref:Win32::Registry@Value+types].
|
|
661
|
+
#
|
|
662
|
+
# +data+ is value data, its class is:
|
|
663
|
+
# REG_SZ, REG_EXPAND_SZ::
|
|
648
664
|
# String
|
|
649
|
-
#
|
|
665
|
+
# REG_MULTI_SZ::
|
|
650
666
|
# Array of String
|
|
651
|
-
#
|
|
667
|
+
# REG_DWORD, REG_DWORD_BIG_ENDIAN, REG_QWORD::
|
|
652
668
|
# Integer
|
|
653
|
-
#
|
|
669
|
+
# REG_BINARY, REG_NONE::
|
|
654
670
|
# String (contains binary data)
|
|
655
671
|
#
|
|
656
|
-
# When
|
|
657
|
-
#
|
|
672
|
+
# When _rtype_ is specified, the value type must be included by
|
|
673
|
+
# _rtype_ array, or +TypeError+ is raised.
|
|
658
674
|
def read(name, *rtype)
|
|
659
675
|
type, data = API.QueryValue(@hkey, name)
|
|
660
676
|
unless rtype.empty? or rtype.include?(type)
|
|
@@ -687,9 +703,9 @@ For detail, see the MSDN[http://msdn.microsoft.com/library/en-us/sysinfo/base/pr
|
|
|
687
703
|
# If the value type is REG_EXPAND_SZ, returns value data whose environment
|
|
688
704
|
# variables are replaced.
|
|
689
705
|
# If the value type is neither REG_SZ, REG_MULTI_SZ, REG_DWORD,
|
|
690
|
-
# REG_DWORD_BIG_ENDIAN, nor REG_QWORD, TypeError is raised.
|
|
706
|
+
# REG_DWORD_BIG_ENDIAN, nor REG_QWORD, +TypeError+ is raised.
|
|
691
707
|
#
|
|
692
|
-
# The meaning of
|
|
708
|
+
# The meaning of _rtype_ is the same as for the #read method.
|
|
693
709
|
#
|
|
694
710
|
def [](name, *rtype)
|
|
695
711
|
type, data = read(name, *rtype)
|
|
@@ -706,7 +722,7 @@ For detail, see the MSDN[http://msdn.microsoft.com/library/en-us/sysinfo/base/pr
|
|
|
706
722
|
# Read a REG_SZ(read_s), REG_DWORD(read_i), or REG_BINARY(read_bin)
|
|
707
723
|
# registry value named name.
|
|
708
724
|
#
|
|
709
|
-
# If the values type does not match, TypeError is raised.
|
|
725
|
+
# If the values type does not match, +TypeError+ is raised.
|
|
710
726
|
def read_s(name)
|
|
711
727
|
read(name, REG_SZ)[1]
|
|
712
728
|
end
|
|
@@ -715,7 +731,7 @@ For detail, see the MSDN[http://msdn.microsoft.com/library/en-us/sysinfo/base/pr
|
|
|
715
731
|
# Read a REG_SZ or REG_EXPAND_SZ registry value named name.
|
|
716
732
|
#
|
|
717
733
|
# If the value type is REG_EXPAND_SZ, environment variables are replaced.
|
|
718
|
-
# Unless the value type is REG_SZ or REG_EXPAND_SZ, TypeError is raised.
|
|
734
|
+
# Unless the value type is REG_SZ or REG_EXPAND_SZ, +TypeError+ is raised.
|
|
719
735
|
#
|
|
720
736
|
def read_s_expand(name)
|
|
721
737
|
type, data = read(name, REG_SZ, REG_EXPAND_SZ)
|
|
@@ -730,7 +746,7 @@ For detail, see the MSDN[http://msdn.microsoft.com/library/en-us/sysinfo/base/pr
|
|
|
730
746
|
# Read a REG_SZ(read_s), REG_DWORD(read_i), or REG_BINARY(read_bin)
|
|
731
747
|
# registry value named name.
|
|
732
748
|
#
|
|
733
|
-
# If the values type does not match, TypeError is raised.
|
|
749
|
+
# If the values type does not match, +TypeError+ is raised.
|
|
734
750
|
#
|
|
735
751
|
def read_i(name)
|
|
736
752
|
read(name, REG_DWORD, REG_DWORD_BIG_ENDIAN, REG_QWORD)[1]
|
|
@@ -740,7 +756,7 @@ For detail, see the MSDN[http://msdn.microsoft.com/library/en-us/sysinfo/base/pr
|
|
|
740
756
|
# Read a REG_SZ(read_s), REG_DWORD(read_i), or REG_BINARY(read_bin)
|
|
741
757
|
# registry value named name.
|
|
742
758
|
#
|
|
743
|
-
# If the values type does not match, TypeError is raised.
|
|
759
|
+
# If the values type does not match, +TypeError+ is raised.
|
|
744
760
|
#
|
|
745
761
|
def read_bin(name)
|
|
746
762
|
read(name, REG_BINARY)[1]
|
|
@@ -750,7 +766,7 @@ For detail, see the MSDN[http://msdn.microsoft.com/library/en-us/sysinfo/base/pr
|
|
|
750
766
|
# Write data to a registry value named name.
|
|
751
767
|
# When name is nil, write to the `default' value.
|
|
752
768
|
#
|
|
753
|
-
# type is
|
|
769
|
+
# +type+ is {value type}[rdoc-ref:Win32::Registry@Value+types].
|
|
754
770
|
# Class of data must be same as which #read
|
|
755
771
|
# method returns.
|
|
756
772
|
#
|
|
@@ -779,11 +795,12 @@ For detail, see the MSDN[http://msdn.microsoft.com/library/en-us/sysinfo/base/pr
|
|
|
779
795
|
#
|
|
780
796
|
# If wtype is specified, the value type is it.
|
|
781
797
|
# Otherwise, the value type is depend on class of value:
|
|
782
|
-
#
|
|
798
|
+
#
|
|
799
|
+
# Integer::
|
|
783
800
|
# REG_DWORD
|
|
784
|
-
#
|
|
801
|
+
# String::
|
|
785
802
|
# REG_SZ
|
|
786
|
-
#
|
|
803
|
+
# Array::
|
|
787
804
|
# REG_MULTI_SZ
|
|
788
805
|
#
|
|
789
806
|
def []=(name, rtype, value = nil)
|
|
@@ -880,19 +897,19 @@ For detail, see the MSDN[http://msdn.microsoft.com/library/en-us/sysinfo/base/pr
|
|
|
880
897
|
|
|
881
898
|
#
|
|
882
899
|
# Returns key information as Array of:
|
|
883
|
-
#
|
|
900
|
+
# num_keys::
|
|
884
901
|
# The number of subkeys.
|
|
885
|
-
#
|
|
902
|
+
# max_key_length::
|
|
886
903
|
# Maximum length of name of subkeys.
|
|
887
|
-
#
|
|
904
|
+
# num_values::
|
|
888
905
|
# The number of values.
|
|
889
|
-
#
|
|
906
|
+
# max_value_name_length::
|
|
890
907
|
# Maximum length of name of values.
|
|
891
|
-
#
|
|
908
|
+
# max_value_length::
|
|
892
909
|
# Maximum length of value of values.
|
|
893
|
-
#
|
|
910
|
+
# descriptor_length::
|
|
894
911
|
# Length of security descriptor.
|
|
895
|
-
#
|
|
912
|
+
# wtime::
|
|
896
913
|
# Last write time as FILETIME(64-bit integer)
|
|
897
914
|
#
|
|
898
915
|
# For detail, see RegQueryInfoKey[http://msdn.microsoft.com/library/en-us/sysinfo/base/regqueryinfokey.asp] Win32 API.
|
data/win32-registry.gemspec
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: win32-registry
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- U.Nakamura
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2025-10
|
|
11
|
+
date: 2025-12-10 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: fiddle
|
|
@@ -31,9 +31,12 @@ executables: []
|
|
|
31
31
|
extensions: []
|
|
32
32
|
extra_rdoc_files: []
|
|
33
33
|
files:
|
|
34
|
+
- ".document"
|
|
35
|
+
- ".rdoc_options"
|
|
34
36
|
- BSDL
|
|
35
37
|
- COPYING
|
|
36
38
|
- README.md
|
|
39
|
+
- docs/win32.rb
|
|
37
40
|
- lib/win32/registry.rb
|
|
38
41
|
- sig/win32/registry.rbs
|
|
39
42
|
- win32-registry.gemspec
|