From: Richard Date: 2007-06-07T15:30:32+09:00 Subject: Re: Finding entries in Windows Registry matching a RE Hi Robert, Thanks for your response. I'm studying the issue and will respond with either "Eureka" or a (hopefully) more sophisticated or nuanced question. Best wishes, Richard On Jun 6, 5:09 am, Robert Klemme wrote: > On 06.06.2007 07:13, Richard wrote: > > > > > Hi, > > > I'd like to be able to search a named hive for keys whose names match > > a given regular expression. > > > I found, for example: > > > require 'win32/registry' > > Win32::Registry::HKEY_CURRENT_USER.open('SOFTWARE\\AdwareAlert\ > > \AdwareAlert\\RegInfo') do |reg| > > puts reg['OrderNo'] > > end > > > which let me specify a specific key in the HKCU hive and print the > > value of one of its entries. > > > I don't actually know why the foregoing is even syntactically correct > > becausehttp://www.ruby-doc.org/stdlib/libdoc/Win32API/rdoc/classes/Win32/Reg... > > says HKEY_CURRENT_USER is a constant in Win32::Registry. > > Why do you think this should disallow the syntax above? It's perfectly > valid Ruby code. And that does not have to do anything with the fact > that HKEY_CURRENT_USER is a constant. > > > Therefore, > > it seems to me that HKEY_CURRENT_USER can't have a method "open". > > The documentation is probably a bit misleading: > > 11:06:11 [~]: ruby -r win32/registry -e > 'k=Win32::Registry::HKEY_CURRENT_USER; p k, k.class, > k.instance_variables.map {|v| "#{v}=#{k.instan > ce_variable_get v}"}' > # > Win32::Registry > ["@keyname=HKEY_CURRENT_USER", "@parent=", "@hkey=2147483649", > "@disposition=2"] > > Does that fix your irritation? :-) > > Btw, if you do this you'll see some methods that might actually do what > you need (find for example). > > ruby -r win32/registry -e 'puts Win32::Registry.instance_methods.sort' > > Kind regards > > robert