如何使用 python wx:Config 访问 Windows 注册表?

发布于 2024-10-10 01:16:45 字数 833 浏览 0 评论 0原文

我读过 http://wxpython.org/docs/api/wx.ConfigBase -class.html

我已经做了一些基本的事情,例如附加的。我能看到的是 Config.Create() 返回某种配置对象,其中包含 里面有关于python的信息。但显然这不是我想要的: 我似乎错过了说“给我一个配置,即 Windows 注册表”的魔力......

谢谢!

>>> import wx
>>> from wx import Config
>>> app=wx.App(False)
>>> config=Config.Create()
>>> config.HasGroup("HKEY_CURRENT_USER")
False
>>> config.GetFirstEntry()
(0, u'', -1)
>>> config.GetFirstGroup()
(1, u'PythonCore', 1)
>>> config.GetNextGroup(1)
(0, u'', -1)
>>> config.GetNumberOfGroups()
1
>>> config.GetPath()
u''
>>> config.HasEntry("PythonCore")
False
>>> config.GetFirstGroup()
(1, u'PythonCore', 1)

I've read http://wxpython.org/docs/api/wx.ConfigBase-class.html

I've done some basic things like the appended. What I can see is that
Config.Create() returns me some sort of configuration object, which has
information about python in it. But clearly that's not what I'm looking for:
I seem to be missing the magic to say "give me a Config that is the Windows Registry"...

Thanks!

GaJ

>>> import wx
>>> from wx import Config
>>> app=wx.App(False)
>>> config=Config.Create()
>>> config.HasGroup("HKEY_CURRENT_USER")
False
>>> config.GetFirstEntry()
(0, u'', -1)
>>> config.GetFirstGroup()
(1, u'PythonCore', 1)
>>> config.GetNextGroup(1)
(0, u'', -1)
>>> config.GetNumberOfGroups()
1
>>> config.GetPath()
u''
>>> config.HasEntry("PythonCore")
False
>>> config.GetFirstGroup()
(1, u'PythonCore', 1)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

如若梦似彩虹 2024-10-17 01:16:45

Config 类不打算用作注册表的通用访问路径。相反,它只是以适合平台的方式方便存储和检索应用程序的首选项数据。换句话说,它将始终使用类似的根位置:

HKCU/Software/VendorName/AppName/

假设 VendorName 和 AppName 已在您的 wx.App 对象上设置。如果您想访问注册表中的其他任何内容,那么您将需要使用其他一些模块来执行此操作,正如已经提到的那样。

The Config classes are not intended to be used as a general purpose access path to the registry. Instead it just facilitates storing and retrieving your application's preferences data, in the way that is appropriate for the platform. In other words, it will always use a root location of something like:

HKCU/Software/VendorName/AppName/

assuming that the VendorName and AppName have been set on your wx.App object. If you want to access anything else in the registry then you'll need to use some other module to do it, as has already been mentioned.

安静被遗忘 2024-10-17 01:16:45

我通常使用 Python 内置 _winreg 模块来完成所有注册表工作。 Tim Golden 的 WMI 模块也很有用,您也可以使用 PyWin32,但我认为 _winreg 是最简单的,除非您需要进行递归删除。

I usually use Python builtin _winreg module for all my Registry work. Tim Golden's WMI module is also useful and you can use PyWin32 as well, but I think _winreg is the easiest unless you need to do a recursive delete.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文