summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/win32/lib/win32/resolv.rb18
1 files changed, 12 insertions, 6 deletions
diff --git a/ext/win32/lib/win32/resolv.rb b/ext/win32/lib/win32/resolv.rb
index ef74a890bb..43ec10cf98 100644
--- a/ext/win32/lib/win32/resolv.rb
+++ b/ext/win32/lib/win32/resolv.rb
@@ -83,7 +83,7 @@ module Win32
unless nvdom.empty?
search = [ nvdom ]
- udmnd = get_item_property(TCPIP_NT, 'UseDomainNameDevolution').to_i
+ udmnd = get_item_property(TCPIP_NT, 'UseDomainNameDevolution', dword: true)
if udmnd != 0
if /^\w+\./ =~ nvdom
devo = $'
@@ -126,17 +126,23 @@ module Win32
[ search.uniq, nameserver.uniq ]
end
- def get_item_property(path, name, expand: false)
+ def get_item_property(path, name, expand: false, dword: false)
if defined?(Win32::Registry)
- Registry::HKEY_LOCAL_MACHINE.open(path) do |reg|
- expand ? reg.read_s_expand(name) : reg.read_s(name)
+ begin
+ Registry::HKEY_LOCAL_MACHINE.open(path) do |reg|
+ if dword
+ reg.read_i(name)
+ else
+ expand ? reg.read_s_expand(name) : reg.read_s(name)
+ end
+ end
rescue Registry::Error
- ""
+ dword ? 0 : ""
end
else
cmd = "Get-ItemProperty -Path 'HKLM:\\#{path}' -Name '#{name}' -ErrorAction SilentlyContinue | Select-Object -ExpandProperty '#{name}'"
output, _ = Open3.capture2('powershell', '-Command', cmd)
- output.strip
+ dword ? output.strip.to_i : output.strip
end
end
end