Win32 :: Registry - delete_value - 系统找不到指定的文件

时间:2013-07-03 21:14:55

标签: ruby windows winapi registry

使用:Windows 7 Pro SP1 x64

我正在尝试删除注册表中的现有值(已验证 使用 regedit )存在以下代码:

require 'win32/registry'

keyname = 'SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate'
access = Win32::Registry::KEY_ALL_ACCESS

Win32::Registry::HKEY_LOCAL_MACHINE.open(keyname, access) do |reg|
    reg.delete_value('SusClientId')
end

其输出产生以下异常:

C:/Ruby200/lib/ruby/2.0.0/win32/registry.rb:768:in `delete_value': The system cannot find the file specified. (Win32::Registry::Error)
    from C:/main_script.rb:7:in `block in <main>'
    from C:/Ruby200/lib/ruby/2.0.0/win32/registry.rb:389:in `open'
    from C:/Ruby200/lib/ruby/2.0.0/win32/registry.rb:496:in `open'
    from C:/main_script.rb:6:in `<main>'

有人能帮助我一些见解吗?提前致谢

0 个答案:

没有答案