Changing registry values with Win32::Registry

I'm trying to change a registry value for an IPTV SDK

This code:

Win32::Registry::HKEY_LOCAL_MACHINE.open("SOFTWARE\\PATH_TO_KEY\
\").write("IgnoreTinyIFrames",Win32::Registry::REG_DWORD,0)

Returns this error:

Win32::Registry::Error: Access is denied.
        from c:/ruby/lib/ruby/1.8/win32/registry.rb:743:in `write'
        from (irb):150
        from :heart::0

Anybody know how I can ensure access to this key?

use Win32::Registry::KEY_WRITE or another KEY_* access specifier as
the next parameter:

Win32::Registry::HKEY_LOCAL_MACHINE.open("SOFTWARE\\PATH_TO_KEY\\",Win32::Registry::KEY_WRITE).write("IgnoreTinyIFrames",Win32::Registry::REG_DWORD,0)

J.

···

On 6/14/07, Collin Miller <collintmiller@gmail.com> wrote:

I'm trying to change a registry value for an IPTV SDK

This code:

Win32::Registry::HKEY_LOCAL_MACHINE.open("SOFTWARE\\PATH_TO_KEY\
\").write("IgnoreTinyIFrames",Win32::Registry::REG_DWORD,0)

Returns this error:

Win32::Registry::Error: Access is denied.
        from c:/ruby/lib/ruby/1.8/win32/registry.rb:743:in `write'
        from (irb):150
        from :heart::0

Anybody know how I can ensure access to this key?

Win32::Registry::Error: Access is denied.
        from c:/ruby/lib/ruby/1.8/win32/registry.rb:743:in `write'
        from (irb):150
        from :heart::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/\.

Look at https://www.ruby-forum.com/topic/76585

···

On Jun 15, 9:51 am, "Jano Svitok" <jan.svi...@gmail.com> wrote:

On 6/14/07, Collin Miller <collintmil...@gmail.com> wrote:

> I'm trying to change a registry value for an IPTV SDK

> This code:

> Win32::Registry::HKEY_LOCAL_MACHINE.open("SOFTWARE\\PATH_TO_KEY\
> \").write("IgnoreTinyIFrames",Win32::Registry::REG_DWORD,0)

> Returns this error:

> Win32::Registry::Error: Access is denied.
> from c:/ruby/lib/ruby/1.8/win32/registry.rb:743:in `write'
> from (irb):150
> from :heart::0

> Anybody know how I can ensure access to this key?

use Win32::Registry::KEY_WRITE or another KEY_* access specifier as
the next parameter:

Win32::Registry::HKEY_LOCAL_MACHINE.open("SOFTWARE\\PATH_TO_KEY\\",Win32::Registry::KEY_WRITE).write("IgnoreTinyIFrames",Win32::Registry::REG_DWORD,0)

J.

Thank you

···

On 6/15/07, dima <dejan.dimic@gmail.com> wrote:

On Jun 15, 9:51 am, "Jano Svitok" <jan.svi...@gmail.com> wrote:
> On 6/14/07, Collin Miller <collintmil...@gmail.com> wrote:
>
> > I'm trying to change a registry value for an IPTV SDK
>
> > This code:
>
> > Win32::Registry::HKEY_LOCAL_MACHINE.open("SOFTWARE\\PATH_TO_KEY\
> > \").write("IgnoreTinyIFrames",Win32::Registry::REG_DWORD,0)
>
> > Returns this error:
>
> > Win32::Registry::Error: Access is denied.
> > from c:/ruby/lib/ruby/1.8/win32/registry.rb:743:in `write'
> > from (irb):150
> > from :heart::0
>
> > Anybody know how I can ensure access to this key?
>
> use Win32::Registry::KEY_WRITE or another KEY_* access specifier as
> the next parameter:
>
Win32::Registry::HKEY_LOCAL_MACHINE.open("SOFTWARE\\PATH_TO_KEY\\",Win32::Registry::KEY_WRITE).write("IgnoreTinyIFrames",Win32::Registry::REG_DWORD,0)
>
> J.

Look at https://www.ruby-forum.com/topic/76585

--
Collin Miller
641 451 0380

How do we handle null value from opened HKEY instance. if
(reg.read_i(name)!="") in below line I have tried but it doesn't work
properly.

Ex:
Win32::Registry::HKEY_LOCAL_MACHINE.open(REG_PATH_1,Win32::Registry::Constants::KEY_ALL_ACCESS)
do |reg|
    if (reg.read_i(name)!="")
              return reg.read_i(name)
            end
    end

I need another instance to open for different REG_PATH. The reason
behind that is if the reg key is in first path then return the value
other wise open the key to read the reg key from different path.

Thanks

···

--
Posted via http://www.ruby-forum.com/.

I have no idea about that API, but if read_i is returning nil for
non-existing keys, you can try this:

unless (key = reg.read_i(name)).nil?
  return key
end

Jesus.

···

On Thu, Jul 8, 2010 at 10:52 AM, Navaneet Kumar <tonavaneet@gmail.com> wrote:

How do we handle null value from opened HKEY instance. if
(reg.read_i(name)!="") in below line I have tried but it doesn't work
properly.

Ex:
Win32::Registry::HKEY_LOCAL_MACHINE.open(REG_PATH_1,Win32::Registry::Constants::KEY_ALL_ACCESS)
do |reg|
if (reg.read_i(name)!="")
return reg.read_i(name)
end
end

I need another instance to open for different REG_PATH. The reason
behind that is if the reg key is in first path then return the value
other wise open the key to read the reg key from different path.

Jesús Gabriel y Galán wrote:

···

On Thu, Jul 8, 2010 at 10:52 AM, Navaneet Kumar <tonavaneet@gmail.com> > wrote:

� �end

I need another instance to open for different REG_PATH. The reason
behind that is if the reg key is in first path then return the value
other wise open the key to read the reg key from different path.

I have no idea about that API, but if read_i is returning nil for
non-existing keys, you can try this:

unless (key = reg.read_i(name)).nil?
  return key
end

Jesus.

Thanks for your reply.

Just clarification, The specified key is not exist not the value is
having null. I mean the 'name' key is not exist in that path. How do we
handle this in ruby.

--
Posted via http://www.ruby-forum.com/\.

I don't know what the API returns in that instance. Can you try this
and show us?

key = reg.read_i(name)
p key

Jesus.

···

On Thu, Jul 8, 2010 at 11:45 AM, Navaneet Kumar <tonavaneet@gmail.com> wrote:

Jesús Gabriel y Galán wrote:

On Thu, Jul 8, 2010 at 10:52 AM, Navaneet Kumar <tonavaneet@gmail.com> >> wrote:

� �end

I need another instance to open for different REG_PATH. The reason
behind that is if the reg key is in first path then return the value
other wise open the key to read the reg key from different path.

I have no idea about that API, but if read_i is returning nil for
non-existing keys, you can try this:

unless (key = reg.read_i(name)).nil?
return key
end

Jesus.

Thanks for your reply.

Just clarification, The specified key is not exist not the value is
having null. I mean the 'name' key is not exist in that path. How do we
handle this in ruby.

Hi,

Jesús Gabriel y Galán wrote:

� �end

I need another instance to open for different REG_PATH. The reason
behind that is if the reg key is in first path then return the value
other wise open the key to read the reg key from different path.

I have no idea about that API, but if read_i is returning nil for
non-existing keys, you can try this:

unless (key = reg.read_i(name)).nil?
return key
end

Jesus.

Thanks for your reply.

Just clarification, The specified key is not exist not the value is
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

···

2010/7/8 Navaneet Kumar <tonavaneet@gmail.com>:

On Thu, Jul 8, 2010 at 10:52 AM, Navaneet Kumar <tonavaneet@gmail.com> >> wrote:

Heesob Park wrote:

Hi,

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?

···

2010/7/8 Navaneet Kumar <tonavaneet@gmail.com>:

--
Posted via http://www.ruby-forum.com/\.

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

···

On 8 July 2010 12:37, Navaneet Kumar <tonavaneet@gmail.com> wrote:

Heesob Park wrote:

Hi,

2010/7/8 Navaneet Kumar <tonavaneet@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...