Prev: Extending OpenStruct to be lazy and recursive
Next: Complie-time polymorphsim and Run-time polymorpshism
From: Navaneet Kumar on 8 Jul 2010 06:37 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 8 Jul 2010 08:45 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 9 Jul 2010 01:34 > 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/.
First
|
Prev
|
Pages: 1 2 Prev: Extending OpenStruct to be lazy and recursive Next: Complie-time polymorphsim and Run-time polymorpshism |