Hi, i'm trying to deal with the winregistry module. But I've one problem. If i have a enumeration of names (enumValueNames), i don't know the the types of this values. I've not found any function inside the module to ask for this. Here my dirty solution to get the type:
import winregistry
proc RegistryGetValueType(h: RegHandle, key: string): string =
  var
    iErr = 0
    readStr: string
    readMultiStr = newSeq[string]()
    readInt32: int32
    readInt64: int64
    readBinary = newSeq[byte]()
  
  try:
    readMultiStr = h.readMultiString(key) # REG_MULTI_SZ
  except RegistryError:
    iErr = 1
  
  if iErr == 1:
    try:
      readStr = h.readExpandString(key)   # REG_EXPAND_SZ
    except RegistryError:
      iErr = 2
  
  if iErr == 2:
    try:
      readStr = h.readString(key)         # REG_SZ
    except RegistryError:
      iErr = 3
  
  if iErr == 3:
    try:
      readInt32 = h.readInt32(key)        # REG_DWORD
    except RegistryError:
      iErr = 4
  
  if iErr == 4:
    try:
      readInt64 = h.readInt64(key)        # REG_QWORD
    except RegistryError:
      iErr = 5
  
  if iErr == 5:
    try:
      readBinary = h.readBinary(key)      # REG_BINARY
    except RegistryError:
      iErr = 6
  
  case iErr
    of 6:
      return "UNKNOWN_TYPE"
    of 5:
      return "REG_BINARY"
    of 4:
      return "REG_QWORD"
    of 3:
      return "REG_DWORD"
    of 2:
      return "REG_SZ"
    of 1:
      return "REG_EXPAND_SZ"
    of 0:
      return "REG_MULTI_SZ"
    else:
      discard
# example
var
  h: RegHandle
try:
  h = open(r"HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control", samRead or samQueryValue)
  echo RegistryGetValueType(h, "PreshutdownOrder")  # output --> REG_MULTI_SZ
except RegistryError:
  echo "Registry Open Error"
finally:
  close(h)
 It works like excepted, but exists any way for a more elegant solution? Thanks for any ideas.