我可以从elisp中读取Windows注册表吗?怎么用?
我只想做这样的事我可以从elisp中读取Windows注册表吗?怎么用?,windows,emacs,registry,Windows,Emacs,Registry,我只想做这样的事 (defun my-fun (reg-path) "reads the value from the given Windows registry path." ...??... ) 是否有一个内置的fn可以这样做 或者windows中是否有内置的命令行工具,我可以运行该工具来检索注册表值 我想象的方法是在cscript.exe中运行一个.js文件来完成这项工作 答复 ==>感谢您使用Oleg。使用命令行实用程序 Emacs命令 (she
(defun my-fun (reg-path)
"reads the value from the given Windows registry path."
...??...
)
是否有一个内置的fn可以这样做
或者windows中是否有内置的命令行工具,我可以运行该工具来检索注册表值
我想象的方法是在cscript.exe中运行一个.js文件来完成这项工作
答复 ==>感谢您使用Oleg。使用命令行实用程序 Emacs命令
(shell命令“REG QUERY KeyName”&可选输出缓冲区ERROR-BUFFER)
允许您运行shell命令。输出被发送到output-BUFFER
以下是我所做的:
(defun my-reg-read (regpath)
"read a path in the Windows registry"
(let ((temp-f (make-temp-file "regread_" nil ".js"))
(js-code "var WSHShell, value, regpath = '';try{ if (WScript.Arguments.length > 0){regpath = WScript.Arguments(0); WSHShell = WScript.CreateObject('WScript.Shell'); value = WSHShell.RegRead(regpath); WScript.Echo(value); }}catch (e1){ WScript.Echo('error reading registry: ' + e1);}")
reg-value)
(with-temp-file temp-f (insert js-code))
(setq reg-value (shell-command-to-string (concat temp-f " " regpath)))
(delete-file temp-f)
reg-value ))
elisp函数创建一个临时文件,然后向其中写入一点javascript逻辑。javascript读取给定路径的windows注册表。然后,elisp fn运行临时文件,将注册表路径传递给read。它删除该文件,然后返回运行该文件的结果 啊哈,比编写自定义Javascript逻辑阅读要容易得多!谢谢。我想您将无法从Emacs Win32访问64位节点。
(defun my-reg-read (regpath)
"read a path in the Windows registry"
(let ((temp-f (make-temp-file "regread_" nil ".js"))
(js-code "var WSHShell, value, regpath = '';try{ if (WScript.Arguments.length > 0){regpath = WScript.Arguments(0); WSHShell = WScript.CreateObject('WScript.Shell'); value = WSHShell.RegRead(regpath); WScript.Echo(value); }}catch (e1){ WScript.Echo('error reading registry: ' + e1);}")
reg-value)
(with-temp-file temp-f (insert js-code))
(setq reg-value (shell-command-to-string (concat temp-f " " regpath)))
(delete-file temp-f)
reg-value ))