LispWorks User Guide and Reference Manual > 23 LispWorks' Operating Environment


23.14 Accessing the Windows registry

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))
   :root :root
   :max-name-size max-name-size
   :max-names max-names
   #'(lambda (hKeyClsid ClassidName)
           (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)
               (progid (win32:query-registry-value "ProgID" nil
                                                   :root hkeyX
                                                   :errorp nil))
               (win32:query-registry-value nil nil
                                           :root hkeyX)
               (win32:query-registry-value "InprocServer32" nil
                                           :root hkeyX
                                           :errorp nil))

LispWorks User Guide and Reference Manual - 22 Dec 2009