miere43 / nim-registry

Deal with Windows Registry from Nim
http://miere.ru/docs/registry/
MIT License
29 stars 5 forks source link

How to read all fonts data #6

Closed super-tomcat closed 5 years ago

super-tomcat commented 5 years ago

I open a handle to windows fonts like this:

h = open("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts", samRead or samQueryValue or samWow64)

But then how do I read all the font names say into a sequence or array?

miere43 commented 5 years ago

Hello.

Update to latest winregistry (version 0.2.1), there should be method enumValueNames. You can use it to read all value names.

import winregistry, sequtils

var handle = 0.RegHandle
try:
  handle = open(
    "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Fonts", 
    samRead or samQueryValue or samWow64)
  echo(toSeq(handle.enumValueNames()))
finally:
  close(handle)

Output:

@["Arial (TrueType)", "Arial Black (TrueType)", "Arial Bold (TrueType)", "Arial Bold Italic (TrueType)", "Arial Italic (TrueType)", "Bahnschrift (TrueType)"...

If you also need font files you can pass each name in enumValueNames to readString.

super-tomcat commented 5 years ago

Hello. Update to latest winregistry (version 0.2.1), there should be method enumValueNames. You can use it to read all value names. import winregistry, sequtils

var handle = 0.RegHandle try: handle = open( "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts", samRead or samQueryValue or samWow64) echo(toSeq(handle.enumValueNames())) finally: close(handle) Output: @["Arial (TrueType)", "Arial Black (TrueType)", "Arial Bold (TrueType)", "Arial Bold Italic (TrueType)", "Arial Italic (TrueType)", "Bahnschrift (TrueType)"...

If you also need font files you can pass each name in enumValueNames to readString.

Hello, I updated to the latest version and its fantastic, keep up the good work