Can't get example to work

Hello,

I must be doing something wrong but I don't know what. I'm trying to
use this example to learn more about the Win32API::Registry library.

require 'win32/registry.rb'

$VERBOSE = nil

appList = []

Win32::Registry::HKEY_LOCAL_MACHINE.open('SOFTWARE\Microsoft\Windows
\CurrentVersion\Uninstall') do |root|

root.each_key do |k|
  Win32::Registry::HKEY_LOCAL_MACHINE.open(root.keyname + "\\#{k[0]}")
do |key|
    key.each do |i|
      if i[0] == "DisplayName"
        appList.push(i[2])
      end
    end
  end
end

When I run it I get: uninitialized constant Win32>

How do I fix this?

Thank you.

Brad

You seem to be missing an "end", but I'll assume that's a copy/paste error.

The code works for me, Ruby 1.8.6 (OneClickInstaller).

As a style note, require lines shouldn't have the ".rb" in them, so do:

require "win32/registry"

Jason

···

On 10/3/07, Brad <bradaskins@gmail.com> wrote:

Hello,

I must be doing something wrong but I don't know what. I'm trying to
use this example to learn more about the Win32API::Registry library.

require 'win32/registry.rb'

$VERBOSE = nil

appList =

Win32::Registry::HKEY_LOCAL_MACHINE.open('SOFTWARE\Microsoft\Windows
\CurrentVersion\Uninstall') do |root|

root.each_key do |k|
        Win32::Registry::HKEY_LOCAL_MACHINE.open(root.keyname +
"\\#{k[0]}")
do |key|
                key.each do |i|
                        if i[0] == "DisplayName"
                                appList.push(i[2])
                        end
                end
        end
end

When I run it I get: uninitialized constant Win32>

How do I fix this?

Thank you.

Brad

I've used the same exact script and it works on my pc.

Did you check to make sure the Win32 libraries are installed. On my pc
they're in
C:\ruby\lib\ruby\1.8\win32

Luis

···

On Oct 3, 8:38 am, Brad <bradask...@gmail.com> wrote:

Hello,

I must be doing something wrong but I don't know what. I'm trying to
use this example to learn more about the Win32API::Registry library.

require 'win32/registry.rb'

$VERBOSE = nil

appList =

Win32::Registry::HKEY_LOCAL_MACHINE.open('SOFTWARE\Microsoft\Windows
\CurrentVersion\Uninstall') do |root|

root.each_key do |k|
        Win32::Registry::HKEY_LOCAL_MACHINE.open(root.keyname + "\\#{k[0]}")
do |key|
                key.each do |i|
                        if i[0] == "DisplayName"
                                appList.push(i[2])
                        end
                end
        end
end

When I run it I get: uninitialized constant Win32>

How do I fix this?

Thank you.

Brad

Hi,

I've found (with most of the win32 stuff) that a reboot often fixes this
- I know it sounds cliched, but I've had similar errors before and a
reboot did the trick...

Sean

···

-----Original Message-----
From: Jason Roelofs [ mailto:jameskilton@gmail.com
<mailto:jameskilton@gmail.com> ]
Sent: 03 October 2007 15:10
To: ruby-talk@ruby-lang.org
Subject: Re: Can't get example to work....

You seem to be missing an "end", but I'll assume that's a copy/paste
error.

The code works for me, Ruby 1.8.6 (OneClickInstaller).

As a style note, require lines shouldn't have the ".rb" in them, so do:

require "win32/registry"

Jason

On 10/3/07, Brad <bradaskins@gmail.com> wrote:

Hello,

I must be doing something wrong but I don't know what. I'm trying to
use this example to learn more about the Win32API::Registry library.

require 'win32/registry.rb'

$VERBOSE = nil

appList =

Win32::Registry::HKEY_LOCAL_MACHINE.open('SOFTWARE\Microsoft\Windows
\CurrentVersion\Uninstall') do |root|

root.each_key do |k|
        Win32::Registry::HKEY_LOCAL_MACHINE.open(root.keyname +
"\\#{k[0]}")
do |key|
                key.each do |i|
                        if i[0] == "DisplayName"
                                appList.push(i[2])
                        end
                end
        end
end

When I run it I get: uninitialized constant Win32>

How do I fix this?

Thank you.

Brad

***********************************************************************************
The Royal Bank of Scotland plc. Registered in Scotland No 90312. Registered Office: 36 St Andrew Square, Edinburgh EH2 2YB.
Authorised and regulated by the Financial Services Authority

This e-mail message is confidential and for use by the
addressee only. If the message is received by anyone other
than the addressee, please return the message to the sender
by replying to it and then delete the message from your
computer. Internet e-mails are not necessarily secure. The
Royal Bank of Scotland plc does not accept responsibility for
changes made to this message after it was sent.

Whilst all reasonable care has been taken to avoid the
transmission of viruses, it is the responsibility of the recipient to
ensure that the onward transmission, opening or use of this
message and any attachments will not adversely affect its
systems or data. No responsibility is accepted by The
Royal Bank of Scotland plc in this regard and the recipient should carry
out such virus and other checks as it considers appropriate.
Visit our websites at:

www.rbs.com/gbm

***********************************************************************************

______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit Email Security
______________________________________________________________________