There is an API for accessing the registry on Microsoft Windows. It is available only in LispWorks for Windows. All of its symbols are in the
win32
package.
Create and delete keys with the functions
create-registry-key
and
delete-registry-key
. Open a key for reading and/or writing with
open-registry-key
and close it with
close-registry-key
, or wrap your registry operation inside the macro
with-registry-key
.
Query the registry with
registry-key-exists-p
,
enum-registry-value
,
collect-registry-values
,
collect-registry-subkeys
,
query-registry-key-info
,
query-registry-value
, and
registry-value
. Write to the registry with
set-registry-value
or
(setf registry-value)
.
For example, this function returns the name, progid and filename for each of the installed ActiveX controls:
(defun collect-control-names (&key insertable
(max-name-size 256)
(max-names most-positive-fixnum))
(win32:collect-registry-subkeys
"CLSID"
:root :root
:max-name-size max-name-size
:max-names max-names
:value-function
#'(lambda (hKeyClsid ClassidName)
(win32:with-registry-key
(hkeyX ClassidName :root hKeyClsid :errorp nil)
(when (and
(win32:registry-key-exists-p "Control"
:root hkeyX)
(if insertable
(win32:registry-key-exists-p "Insertable"
:root hkeyX)
t))
(when-let
(progid (win32:query-registry-value "ProgID" nil
:root hkeyX
:errorp nil))
(values
(list
(win32:query-registry-value nil nil
:root hkeyX)
progid
(win32:query-registry-value "InprocServer32" nil
:root hkeyX
:errorp nil))
t)))))))