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:
parent
b36182b0a4
commit
085580a2c8
2 changed files with 25 additions and 8 deletions
|
|
@ -54,16 +54,18 @@ proc getUnicodeValue*(path, key: string; handle: HKEY): string =
|
||||||
var newHandle: HKEY
|
var newHandle: HKEY
|
||||||
call regOpenKeyEx(handle, hh, 0, KEY_READ or KEY_WOW64_64KEY, newHandle)
|
call regOpenKeyEx(handle, hh, 0, KEY_READ or KEY_WOW64_64KEY, newHandle)
|
||||||
call regGetValue(newHandle, nil, kk, flags, nil, nil, addr bufsize)
|
call regGetValue(newHandle, nil, kk, flags, nil, nil, addr bufsize)
|
||||||
var res = newWideCString("", bufsize)
|
if bufSize > 0:
|
||||||
call regGetValue(newHandle, nil, kk, flags, nil, cast[pointer](res),
|
var res = newWideCString(bufsize)
|
||||||
addr bufsize)
|
call regGetValue(newHandle, nil, kk, flags, nil, addr res[0],
|
||||||
result = res $ bufsize
|
addr bufsize)
|
||||||
|
result = res $ bufsize
|
||||||
call regCloseKey(newHandle)
|
call regCloseKey(newHandle)
|
||||||
else:
|
else:
|
||||||
var res = newWideCString("", bufsize)
|
if bufSize > 0:
|
||||||
call regGetValue(handle, hh, kk, flags, nil, cast[pointer](res),
|
var res = newWideCString(bufsize)
|
||||||
addr bufsize)
|
call regGetValue(handle, hh, kk, flags, nil, addr res[0],
|
||||||
result = res $ bufsize
|
addr bufsize)
|
||||||
|
result = res $ bufsize
|
||||||
|
|
||||||
proc regSetValue(key: HKEY, lpSubKey, lpValueName: WideCString,
|
proc regSetValue(key: HKEY, lpSubKey, lpValueName: WideCString,
|
||||||
dwType: int32; lpData: WideCString; cbData: int32): int32 {.
|
dwType: int32; lpData: WideCString; cbData: int32): int32 {.
|
||||||
|
|
|
||||||
15
tests/stdlib/tregistry.nim
Normal file
15
tests/stdlib/tregistry.nim
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
discard """
|
||||||
|
disabled: "unix"
|
||||||
|
matrix: "--gc:refc; --gc:arc"
|
||||||
|
"""
|
||||||
|
|
||||||
|
when defined(windows):
|
||||||
|
import std/registry
|
||||||
|
|
||||||
|
block: # bug #14010
|
||||||
|
let path = "Environment"
|
||||||
|
let key = "D20210328T202842_key"
|
||||||
|
let val = "D20210328T202842_val"
|
||||||
|
let handle = HKEY_CURRENT_USER
|
||||||
|
setUnicodeValue("Environment", key, val, handle)
|
||||||
|
doAssert getUnicodeValue(path, key, handle) == val
|
||||||
Loading…
Add table
Add a link
Reference in a new issue