简体   繁体   English

如何在lua中递归地走Windows注册表?

[英]How do I walk recursively windows registry in lua?

I'm coming from linux land so bear with me please. 我来自linux领域,请多多包涵。

I want to walk through windows registry recursively. 我想递归地浏览Windows注册表。 All I've managed to do so far get the values of individual keys 到目前为止,我所能做的所有事情都是获取单个键的值

> require 'luacom'
> sh = luacom.CreateObject "WScript.Shell"
> = sh:RegRead "HKCU\\Console\\ColorTable01"
8388608

yet see no way to iterate registry nodes... 仍然没有办法迭代注册表节点...

If you need to do anything Windows-specific with Lua, your first port of call should be the winapi library; 如果您需要使用Lua进行Windows特定的任何操作,则第一个调用端口应该是winapi库。 in this case, you can enumerate over Registry keys with open_reg_key() and Regkey:get_keys() like so: 在这种情况下,您可以使用open_reg_key()Regkey:get_keys()枚举注册表项,如下所示:

require "winapi"
local key, err = winapi.open_reg_key [[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows]]
local t = key:get_keys()
for k,v in ipairs(t) do print(k,v) end
-- 1       CurrentVersion
-- 2       HTML Help
-- ...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM