diff options
Diffstat (limited to 'ext')
-rw-r--r-- | ext/win32/lib/win32/registry.rb | 10 | ||||
-rw-r--r-- | ext/win32/lib/win32/resolv.rb | 15 |
2 files changed, 21 insertions, 4 deletions
diff --git a/ext/win32/lib/win32/registry.rb b/ext/win32/lib/win32/registry.rb index f3655b78d3..a88d7e63d0 100644 --- a/ext/win32/lib/win32/registry.rb +++ b/ext/win32/lib/win32/registry.rb @@ -643,7 +643,9 @@ For detail, see the MSDN[http://msdn.microsoft.com/library/en-us/sysinfo/base/pr def read(name, *rtype) type, data = API.QueryValue(@hkey, name) unless rtype.empty? or rtype.include?(type) - raise TypeError, "Type mismatch (expect #{rtype.inspect} but #{type} present)" + raise TypeError, "Type mismatch (expect [#{ + rtype.map{|t|Registry.type2name(t)}.join(', ')}] but #{ + Registry.type2name(type)} present)" end case type when REG_SZ, REG_EXPAND_SZ @@ -659,7 +661,7 @@ For detail, see the MSDN[http://msdn.microsoft.com/library/en-us/sysinfo/base/pr when REG_QWORD [ type, API.unpackqw(data) ] else - raise TypeError, "Type #{type} is not supported." + raise TypeError, "Type #{Registry.type2name(type)} is not supported." end end @@ -682,7 +684,7 @@ For detail, see the MSDN[http://msdn.microsoft.com/library/en-us/sysinfo/base/pr when REG_EXPAND_SZ Registry.expand_environ(data) else - raise TypeError, "Type #{type} is not supported." + raise TypeError, "Type #{Registry.type2name(type)} is not supported." end end @@ -755,7 +757,7 @@ For detail, see the MSDN[http://msdn.microsoft.com/library/en-us/sysinfo/base/pr when REG_QWORD data = API.packqw(data.to_i) else - raise TypeError, "Unsupported type #{type}" + raise TypeError, "Unsupported type #{Registry.type2name(type)}" end API.SetValue(@hkey, name, type, data, data.bytesize + termsize) end diff --git a/ext/win32/lib/win32/resolv.rb b/ext/win32/lib/win32/resolv.rb index 183d5d38da..d71ed98f78 100644 --- a/ext/win32/lib/win32/resolv.rb +++ b/ext/win32/lib/win32/resolv.rb @@ -46,6 +46,21 @@ if info.unpack('V5')[4] == 2 # VER_PLATFORM_WIN32_NT # Windows NT #==================================================================== module_eval <<-'__EOS__', __FILE__, __LINE__+1 + module SZ + refine Registry do + # ad hoc workaround for broken registry + def read_s(key) + type, str = read(key) + unless type == Registry::REG_SZ + warn "Broken registry, #{name}\\#{key} was #{Registry.type2name(type)}, ignored" + return String.new + end + str + end + end + end + using SZ + TCPIP_NT = 'SYSTEM\CurrentControlSet\Services\Tcpip\Parameters' class << self |