]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/windows/registry/registry.factor
Reformat
[factor.git] / basis / windows / registry / registry.factor
index 21e326539ff59fc7b5b7ed925a760e07b108ea5d..b700c9e78dad7717131c92a7248188c5d0c4e1b0 100644 (file)
@@ -1,9 +1,9 @@
 ! Copyright (C) 2010 Doug Coleman.
 ! Copyright (C) 2018 Alexander Ilin.
-! See http://factorcode.org/license.txt for BSD license.
+! See https://factorcode.org/license.txt for BSD license.
 USING: accessors alien.c-types alien.data byte-arrays
 classes.struct continuations io.encodings.string
-io.encodings.utf16n kernel literals locals math sequences sets
+io.encodings.utf16 kernel literals locals math sequences sets
 splitting windows windows.advapi32 windows.errors
 windows.kernel32 windows.time windows.types ;
 IN: windows.registry
@@ -218,3 +218,10 @@ TUPLE: registry-enum-key ;
         [ hkey value-name type DWORD deref ] dip dup length
         set-reg-key
     ] with-open-registry-key ;
+
+:: query-registry ( key subkey value-name -- value )
+    key subkey KEY_READ [
+        value-name f 0 DWORD <ref> dup :> ptype MAX_PATH <byte-array> reg-query-value-ex
+        ptype DWORD deref dup :> type ${ REG_SZ REG_EXPAND_SZ REG_MULTI_SZ } in?
+        [ utf16n decode type REG_MULTI_SZ = [ "\0" split 2 ] [ 1 ] if head* ] when
+    ] with-open-registry-key ;