diff options
Diffstat (limited to 'ext/win32/lib')
-rw-r--r-- | ext/win32/lib/win32/registry.rb | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/ext/win32/lib/win32/registry.rb b/ext/win32/lib/win32/registry.rb index 668f573edb..74cc77dc9f 100644 --- a/ext/win32/lib/win32/registry.rb +++ b/ext/win32/lib/win32/registry.rb @@ -725,11 +725,14 @@ For detail, see the MSDN[http://msdn.microsoft.com/library/en-us/sysinfo/base/pr # method returns. # def write(name, type, data) + termsize = 0 case type when REG_SZ, REG_EXPAND_SZ - data = data.to_s + "\0" + data = data.encode(WCHAR) + termsize = WCHAR_SIZE when REG_MULTI_SZ - data = data.to_a.join("\0") + "\0\0" + data = data.to_a.map {|s| s.encode(WCHAR)}.join(WCHAR_NUL) << WCHAR_NUL + termsize = WCHAR_SIZE when REG_BINARY data = data.to_s when REG_DWORD @@ -741,7 +744,7 @@ For detail, see the MSDN[http://msdn.microsoft.com/library/en-us/sysinfo/base/pr else raise TypeError, "Unsupported type #{type}" end - API.SetValue(@hkey, name, type, data, data.length) + API.SetValue(@hkey, name, type, data, data.bytesize + termsize) end # |