fix #14010(fix std/registry + arc) (#17551)

* fix nim js cmp fails at CT

* fix #14010

* Update tests/stdlib/tregistry.nim

Co-authored-by: Timothee Cour <timothee.cour2@gmail.com>

* Update tregistry.nim

Co-authored-by: Timothee Cour <timothee.cour2@gmail.com>
This commit is contained in:
flywind 2021-03-29 16:50:58 +08:00 • committed by GitHub
commit 085580a2c8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 8 deletions

View file

@ -54,16 +54,18 @@ proc getUnicodeValue*(path, key: string; handle: HKEY): string =
var newHandle: HKEY
call regOpenKeyEx(handle, hh, 0, KEY_READ or KEY_WOW64_64KEY, newHandle)
call regGetValue(newHandle, nil, kk, flags, nil, nil, addr bufsize)
var res = newWideCString("", bufsize)
call regGetValue(newHandle, nil, kk, flags, nil, cast[pointer](res),
addr bufsize)
result = res $ bufsize
if bufSize > 0:
var res = newWideCString(bufsize)
call regGetValue(newHandle, nil, kk, flags, nil, addr res[0],
addr bufsize)
result = res $ bufsize
call regCloseKey(newHandle)
else:
var res = newWideCString("", bufsize)
call regGetValue(handle, hh, kk, flags, nil, cast[pointer](res),
addr bufsize)
result = res $ bufsize
if bufSize > 0:
var res = newWideCString(bufsize)
call regGetValue(handle, hh, kk, flags, nil, addr res[0],
addr bufsize)
result = res $ bufsize
proc regSetValue(key: HKEY, lpSubKey, lpValueName: WideCString,
dwType: int32; lpData: WideCString; cbData: int32): int32 {.