我可以从elisp中读取Windows注册表吗?怎么样?

Che*_*eso 4 windows registry emacs

我只是想做这样的事情

(defun my-fun (reg-path) 
  "reads the value from the given Windows registry path."
     ...??...
)
Run Code Online (Sandbox Code Playgroud)

是否有一个内置的fn这样做?

或者是否有一个内置于Windows的命令行工具,我可以运行以检索reg值?

我想象的方式是在cscript.exe中运行一个完成工作的.js文件.


回答

(defun my-reg-read (regpath)
  "read a path in the Windows registry. This probably works for string 
  values only. If the path does not exist, it returns nil. "
  (let ((reg.exe (concat (getenv "windir") "\\system32\\reg.exe"))
        tokens last-token)

    (setq reg-value (shell-command-to-string (concat reg.exe " query " regpath))
          tokens (split-string reg-value nil t)
          last-token (nth (1- (length tokens)) tokens))

    (and (not (string= last-token "value.")) last-token)))
Run Code Online (Sandbox Code Playgroud)

==>谢谢Oleg.

Ole*_*liv 5

使用reg命令行实用程序.

Emacs命令

(shell-command "REG QUERY KeyName" &optional OUTPUT-BUFFER ERROR-BUFFER)

允许您运行shell命令.输出发送到OUTPUT-BUFFER.