From: Navaneet Kumar on
Heesob Park wrote:
> Hi,
>
> 2010/7/8 Navaneet Kumar <tonavaneet(a)gmail.com>:
>>> non-existing keys, you can try this:
>> having null. I mean the 'name' key is not exist in that path. How do we
>> handle this in ruby.
>>
> You can handle it like this:
>
> begin
> if (reg.read_i(name)!="")
> return reg.read_i(name)
> end
> rescue Win32::Registry::Error => e
> if e.code == 2
> puts "#{name} key not exist!"
> end
> end
>
>
> Regards,
>
> Park Heesob

Thanks Park...

I was trying the same and it works for me. Is is possible to handle
without handling the exception?
--
Posted via http://www.ruby-forum.com/.

From: Michal Suchanek on
On 8 July 2010 12:37, Navaneet Kumar <tonavaneet(a)gmail.com> wrote:
> Heesob Park wrote:
>> Hi,
>>
>> 2010/7/8 Navaneet Kumar <tonavaneet(a)gmail.com>:
>>>> non-existing keys, you can try this:
>>> having null. I mean the 'name' key is not exist in that path. How do we
>>> handle this in ruby.
>>>
>> You can handle it like this:
>>
>>   begin
>>   if (reg.read_i(name)!="")
>>              return reg.read_i(name)
>>         end
>>   rescue Win32::Registry::Error => e
>>   if e.code == 2
>>     puts "#{name} key not exist!"
>>   end
>>   end
>>
>>
>> Regards,
>>
>> Park Heesob
>
> Thanks Park...
>
>

I would do something like

reg.read_i(name) rescue nil

unless I wanted to know exactly what went wrong.

I wrote some hacks for replacing key values in registry so I can dig
them up if you want.

HTH

Michal

From: Roger Pack on
> Win32::Registry::Error: Access is denied.
> from c:/ruby/lib/ruby/1.8/win32/registry.rb:743:in `write'
> from (irb):150
> from ♥:0
>
> Anybody know how I can ensure access to this key?

This might help:

http://wiki.github.com/rdp/ruby_tutorials_core/win32registry
--
Posted via http://www.ruby-forum.com/.