Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > registry.rb problem?

Reply
Thread Tools

registry.rb problem?

 
 
Phil Tomson
Guest
Posts: n/a
 
      12-20-2003
I just found out about registry.rb in the Win32 distribution of Ruby (it's
for accessing the Windows registry).

However, when I tried the sample script:



require 'win32/registry.rb'

Win32::Registry::HKEY_CURRENT_USER.open('SOFTWARE\ foo') do |reg|

value = reg['foo'] # read a value

value = reg['foo', Win32::Registry::REG_SZ] # read a value with
type

type, value = reg.read('foo') # read a value

#reg['foo'] = 'bar' # write a value

#reg['foo', Win32::Registry::REG_SZ] = 'bar' # write a value
with type

#reg.write('foo', Win32::Registry::REG_SZ, 'bar') # write a value



reg.each_value { |name, type, data|

puts "name is: #{name}, type is: #{type}, data is: #{data}"

} # Enumerate values


end



I got:

c:/programs/ruby/lib/ruby/1.8/win32/registry.rb:340:in `initialize':
uninitializ

ed constant Win32::Registry::Error::Errno (NameError)

from c:/programs/ruby/lib/ruby/1.8/win32/registry.rb:340:in
`initialize'



from c:/programs/ruby/lib/ruby/1.8/win32/registry.rb:395:in
`exception'

from c:/programs/ruby/lib/ruby/1.8/win32/registry.rb:395:in
`raise'

from c:/programs/ruby/lib/ruby/1.8/win32/registry.rb:395:in
`check'

from c:/programs/ruby/lib/ruby/1.8/win32/registry.rb:417:in
`OpenKey'

from c:/programs/ruby/lib/ruby/1.8/win32/registry.rb:525:in
`open'

from c:/programs/ruby/lib/ruby/1.8/win32/registry.rb:605:in
`open'

from registry.rb:2





Any ideas?

Phil
 
Reply With Quote
 
 
 
 
daz
Guest
Posts: n/a
 
      12-20-2003
Phil Tomson wrote:

> I just found out about registry.rb in the Win32 distribution of Ruby (it's
> for accessing the Windows registry).
>
>
> I got:
>
> c:/programs/ruby/lib/ruby/1.8/win32/registry.rb:340:in `initialize':
> uninitialized constant Win32::Registry::Error::Errno (NameError)
>
> <snips>
>
>
> Any ideas?
>
> Phil



There were slight changes in Rev 1.2, yours is Rev 1.1

---------------------------
? Quick fix:

Replace line 333:
class Error < ::SystemCallError
with:
class Error < ::StandardError

---------------------------

Or d/l from CVSweb
http://www.ruby-lang.org/cgi-bin/cvs...32/registry.rb

# Next to "Revision 1.2", right-click on (download) and "Save target as ..."
(depending on your browser)


I think Usa is the [author/]maintainer (U.Nakamura <(E-Mail Removed)>)



daz



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments