使用RegQueryInfoKey
我是编程新手,我想知道注册表项中的条目数。我认为条目称为子项,但我不确定。我正在尝试使用 RegQueryInfoKey() 但由于我是初学者,所以我不完全理解 MSDN 网页。
HKEY hKey = HKEY_LOCAL_MACHINE;
char regpath[] = "SOFTWARE\\MyApplication\\"
LPDWORD numberofEntries;
RegOpenKeyEx(hKey, regpath, 0, KEY_READ, &hKey);
RegQueryInfoKey(hKey, NULL, NULL, NULL, numberofEntries, NULL);
然后我想打印这个键中的条目数。上面的代码不起作用,应用程序崩溃。
它是如何完成的? 谢谢
I am new to programming, I would like to know the number of entries in a registry key. I think entries are called subkeys but I am not sure. I am trying to use RegQueryInfoKey() but I don't fully understand the MSDN webpage since I am beginner.
HKEY hKey = HKEY_LOCAL_MACHINE;
char regpath[] = "SOFTWARE\\MyApplication\\"
LPDWORD numberofEntries;
RegOpenKeyEx(hKey, regpath, 0, KEY_READ, &hKey);
RegQueryInfoKey(hKey, NULL, NULL, NULL, numberofEntries, NULL);
then I would like to printf the number of entries in this key. The code above doesn't work, the app crash.
How is it done?
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
RegQueryInfoKey
具有12个参数。你只通过了 6。我无法理解它是如何编译的——也许你提供了你自己的RegQueryInfoKey
定义,而不是 Windows 头文件中的定义。也许您对
RegQueryInfoKey
的许多参数都标记为可选这一事实感到困惑。这仅意味着您可以将 NULL 传递到函数中,而不意味着您可以完全省略参数。RegQueryInfoKey
has 12 parameters. You are only passing 6. I can't understand how that even compiles—perhaps you are providing your own definition ofRegQueryInfoKey
rather than the one from the windows header files.Perhaps you are getting confused by the fact that many of the parameters to
RegQueryInfoKey
are marked as optional. This only means that you can passNULL
into the function and not that you can omit the parameters altogether.