where to look for API win32/registry

A

Alexandru Popescu

Hi!

I am trying to write a small script that cleans up the registry after starting Skype (which on
regular basis registers itself in Run).

What I am looking now is the API of Win32::Registry. Where can I find it?

So far I have done this:

require 'win32/registry'
Run_branch = 'Software\Microsoft\Windows\CurrentVersion\Run'
Skype_key = 'Skype'
Win32::Registry::HKEY_CURRENT_USER.open(Run_branch, Win32::Registry::Constants::KEY_ALL_ACCESS) do |
| reg |
reg_typ, reg_val = reg.read(Skype_key)
puts "type: #{reg_typ}"
puts "val : #{reg_val}"
end

type: 1
val : "C:\Program Files\Skype\Phone\Skype.exe" /nosplash /minimized

As you can see I was able to identify the key, but I don't know what can I do next. Win32::Registry
doesn't seem to have a method to delete or modify the content of the key.

On a more general note usually when you want to use such an extension where should I look for
documentation?

thanks a lot,

/alex
 
A

Alan Chen

Alexandru said:
Hi!

I am trying to write a small script that cleans up the registry after starting Skype (which on
regular basis registers itself in Run).

What I am looking now is the API of Win32::Registry. Where can I find it?

So far I have done this:

require 'win32/registry'
Run_branch = 'Software\Microsoft\Windows\CurrentVersion\Run'
Skype_key = 'Skype'
Win32::Registry::HKEY_CURRENT_USER.open(Run_branch, Win32::Registry::Constants::KEY_ALL_ACCESS) do |
| reg |
reg_typ, reg_val = reg.read(Skype_key)
puts "type: #{reg_typ}"
puts "val : #{reg_val}"

If you haven't built, or don't have an install of, the rdoc
documentation for Ruby, you can find it at
http://www.ruby-doc.org/stdlib/

Modifying and deleting is fairly easy, IIRC:

reg[Skype_key] = "new value"
reg.delete_key(Skype_key)

Cheers,
- alan
 
A

Alexandru Popescu

#: Alan Chen changed the world a bit at a time by saying on 9/29/2005 12:46 AM :#
Alexandru said:
Hi!

I am trying to write a small script that cleans up the registry after starting Skype (which on
regular basis registers itself in Run).

What I am looking now is the API of Win32::Registry. Where can I find it?

So far I have done this:

require 'win32/registry'
Run_branch = 'Software\Microsoft\Windows\CurrentVersion\Run'
Skype_key = 'Skype'
Win32::Registry::HKEY_CURRENT_USER.open(Run_branch, Win32::Registry::Constants::KEY_ALL_ACCESS) do |
| reg |
reg_typ, reg_val = reg.read(Skype_key)
puts "type: #{reg_typ}"
puts "val : #{reg_val}"

If you haven't built, or don't have an install of, the rdoc
documentation for Ruby, you can find it at
http://www.ruby-doc.org/stdlib/

Modifying and deleting is fairly easy, IIRC:

reg[Skype_key] = "new value"
reg.delete_key(Skype_key)

Cheers,
- alan

delete_key results in error:

Win32::Registry::Error: The system cannot find the file specified.
from c:/ruby/ruby-1.8.2-15/lib/ruby/1.8/win32/registry.rb:800:in `delete_key'
from (irb):6
from (irb):5:in `open'
from c:/ruby/ruby-1.8.2-15/lib/ruby/1.8/win32/registry.rb:608:in `open'
from (irb):5

/alex
 
D

daz

The first 260 lines of registry.rb is an rdoc description
although I couldn't find an entry on ruby-doc.
Readable enough though.
delete_key results in error:

You want delete_value(Skype_key) # (alias delete)

Your key is 'Run' ... 'Run' can have multiple values ...
.... each value can have data associated with it.

So, one 'Run' value is 'Skype' which has data of "C:\...Skype.exe...".

Terminology/apology (skip the WMI stuff):
http://www.microsoft.com/technet/scriptcenter/resources/qanda/mar05/hey0304.mspx


Whatever; I call 'Skype' a key and the data its value because
'[key] = value' fits better than '[value] = data', in my head.

daz
 
J

James Britt

daz said:
The first 260 lines of registry.rb is an rdoc description
although I couldn't find an entry on ruby-doc.

http://www.ruby-doc.org/stdlib/libdoc/Win32API/rdoc/files/Win32API/lib/win32/registry_rb.html
http://www.ruby-doc.org/stdlib/libdoc/Win32API/rdoc/classes/Win32/Registry/API.html

James

--

http://www.ruby-doc.org - The Ruby Documentation Site
http://www.rubyxml.com - News, Articles, and Listings for Ruby & XML
http://www.rubystuff.com - The Ruby Store for Ruby Stuff
http://www.jamesbritt.com - Playing with Better Toys
 
A

Alexandru Popescu

Yep, usually I am using the same terms, but it seems once again that
MS is smarter :).

/alex
--
the_mindstorm.


The first 260 lines of registry.rb is an rdoc description
although I couldn't find an entry on ruby-doc.
Readable enough though.
delete_key results in error:

You want delete_value(Skype_key) # (alias delete)

Your key is 'Run' ... 'Run' can have multiple values ...
.... each value can have data associated with it.

So, one 'Run' value is 'Skype' which has data of "C:\...Skype.exe...".

Terminology/apology (skip the WMI stuff):
http://www.microsoft.com/technet/scriptcenter/resources/qanda/mar05/hey03= 04.mspx


Whatever; I call 'Skype' a key and the data its value because
'[key] =3D value' fits better than '[value] =3D data', in my head.

daz
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top