Puis-je lire le registre Windows depuis elisp? Comment?

Je veux juste faire quelque chose comme ça

(defun my-fun (reg-path) "reads the value from the given Windows registry path." ...??... ) 

y a-t-il une fn intégrée qui fait cela?

ou existe-t-il un outil de ligne de commande intégré à Windows que je peux exécuter pour récupérer une valeur reg?

La façon dont j’imagine le faire est d’exécuter un fichier .js dans cscript.exe qui fait le travail.


RÉPONDRE

 (defun my-reg-read (regpath) "read a path in the Windows registry. This probably works for ssortingng 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-ssortingng (concat reg.exe " query " regpath)) tokens (split-ssortingng reg-value nil t) last-token (nth (1- (length tokens)) tokens)) (and (not (ssortingng= last-token "value.")) last-token))) 

==> Merci à Oleg.

Utilisez l’utilitaire de ligne de commande reg .

Commande Emacs

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

vous permet d’exécuter une commande shell. La sortie est envoyée au OUTPUT-BUFFER .

Voici ce que j’ai fait:

 (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-ssortingng (concat temp-f " " regpath))) (delete-file temp-f) reg-value )) 

La fonction elisp crée un fichier temporaire, puis y inscrit un peu de logique javascript. le javascript lit le registre Windows pour un chemin donné. Le fichier elisp fn exécute ensuite le fichier temporaire, en passant le chemin du registre à lire. Il supprime le fichier, puis renvoie le résultat de son exécution.