Project

General

Profile

Actions

Bug #6447

closed

Win32::Registry#keys always returns [] even if there are keys

Added by rogerdpack (Roger Pack) almost 12 years ago. Updated almost 12 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
ruby -v:
tcs-ruby 1.9.3p28 (2012-01-28, TCS patched 2012-01-30) [i386-mingw32]
Backport:
[ruby-core:45112]

Description

ex:
require 'win32/registry'
@screen_reg = Win32::Registry::HKEY_CURRENT_USER.create "Software\os_screen_capture"; @screen_reg['last_init_config_was'] = 3

@screen_reg.keys
=> []

also each_key doesn't do anything, as well. The "each" method does work as expected however. Sorry if this is a dupe.

Updated by jonforums (Jon Forums) almost 12 years ago

does this also occur on 1.9.3p194 from rubyinstaller.org?

Updated by jonforums (Jon Forums) almost 12 years ago

it's a value not a key, right?

puts RUBY_DESCRIPTION
ruby 1.9.3p211 (2012-05-12 revision 35630) [i386-mingw32]
=> nil
...
screen_reg['last_init_config_was'] = 3
=> 3
screen_reg['last_init_config_was']
=> 3
screen_reg.num_values
=> 1
screen_reg.num_keys
=> 0
screen_reg.each_key { |k| puts k }
=> 0
screen_reg.each_value { |v| puts v }
last_init_config_was
=> 1
screen_reg.each { |i| puts i }
last_init_config_was
=> 1

Updated by jonforums (Jon Forums) almost 12 years ago

I think it's a terminology thing, not a bug. Here's one more with subkey's containing values:

require 'win32/registry'
=> true
pdf = Win32::Registry::HKEY_CURRENT_USER.open 'Software\PDFCreator'
=> #<Win32::Registry key="HKEY_CURRENT_USER\Software\PDFCreator">
pdf.num_keys
=> 2
pdf.each_key do |pk|
| pdf.open(pk) do |sk|
| puts sk.name
| sk.each_value { |v| puts " #{v}" }
| end
| end
HKEY_CURRENT_USER\Software\PDFCreator\Ghostscript
DirectoryGhostscriptBinaries
DirectoryGhostscriptFonts
DirectoryGhostscriptLibraries
DirectoryGhostscriptResource
HKEY_CURRENT_USER\Software\PDFCreator\Program
AutosaveDirectory
LastsaveDirectory
Language
PrinterTemppath
=> 2

Updated by usa (Usaku NAKAMURA) almost 12 years ago

  • Status changed from Open to Rejected

Yes, Jon is right.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0