mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
win32/registry.rb: slice in WCHARs
* ext/win32/lib/win32/registry.rb (Win32::Registry::API#Enum{Value,Key): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48333 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
0babd24827
commit
0066d95fd6
2 changed files with 12 additions and 4 deletions
|
@ -1,3 +1,8 @@
|
|||
Sun Nov 9 12:09:38 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* ext/win32/lib/win32/registry.rb (Win32::Registry::API#Enum{Value,Key):
|
||||
ditto.
|
||||
|
||||
Sun Nov 9 11:48:40 2014 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* test/net/http: Examine webrick log.
|
||||
|
|
|
@ -66,6 +66,7 @@ For detail, see the MSDN[http://msdn.microsoft.com/library/en-us/sysinfo/base/pr
|
|||
|
||||
WCHAR = Encoding::UTF_16LE
|
||||
WCHAR_NUL = "\0".encode(WCHAR).freeze
|
||||
WCHAR_CR = "\r".encode(WCHAR).freeze
|
||||
WCHAR_SIZE = WCHAR_NUL.bytesize
|
||||
LOCALE = Encoding.find(Encoding.locale_charmap)
|
||||
|
||||
|
@ -175,8 +176,10 @@ For detail, see the MSDN[http://msdn.microsoft.com/library/en-us/sysinfo/base/pr
|
|||
@code = code
|
||||
msg = WCHAR_NUL * 1024
|
||||
len = FormatMessageW.call(0x1200, 0, code, 0, msg, 1024, 0)
|
||||
msg = msg[0, len].encode(LOCALE)
|
||||
super msg.tr("\r".encode(msg.encoding), '').chomp
|
||||
msg = msg.byteslice(0, len * WCHAR_SIZE)
|
||||
msg.delete!(WCHAR_CR)
|
||||
msg.chomp!
|
||||
super msg.encode(LOCALE)
|
||||
end
|
||||
attr_reader :code
|
||||
end
|
||||
|
@ -290,7 +293,7 @@ For detail, see the MSDN[http://msdn.microsoft.com/library/en-us/sysinfo/base/pr
|
|||
name = WCHAR_NUL * Constants::MAX_KEY_LENGTH
|
||||
size = packdw(Constants::MAX_KEY_LENGTH)
|
||||
check RegEnumValueW.call(hkey, index, name, size, 0, 0, 0, 0)
|
||||
name[0, unpackdw(size)]
|
||||
name.byteslice(0, unpackdw(size) * WCHAR_SIZE)
|
||||
end
|
||||
|
||||
def EnumKey(hkey, index)
|
||||
|
@ -298,7 +301,7 @@ For detail, see the MSDN[http://msdn.microsoft.com/library/en-us/sysinfo/base/pr
|
|||
size = packdw(Constants::MAX_KEY_LENGTH)
|
||||
wtime = ' ' * 8
|
||||
check RegEnumKeyExW.call(hkey, index, name, size, 0, 0, 0, wtime)
|
||||
[ name[0, unpackdw(size)], unpackqw(wtime) ]
|
||||
[ name.byteslice(0, unpackdw(size) * WCHAR_SIZE), unpackqw(wtime) ]
|
||||
end
|
||||
|
||||
def QueryValue(hkey, name)
|
||||
|
|
Loading…
Reference in a new issue