使用C ++来导入注册表文件 [英] Using C++ to import registry files
问题描述
我有得到下面这个简单的code正常运行的一些问题:
I'm having some problems of getting the following simple code to run correctly:
#include <process.h>
int main( void )
{
system("foo.reg"); //why does this NOT WORK?!
//system("reg import foo.reg"); //why does this NOT WORK?!
//system("regedit \"foo.reg\""); //why does this NOT WORK?!
return 0;
}
注册表文件位于在编译的可执行文件的目录。的 foo.reg 的成功运行,当我从命令行中运行,但运行上面的程序只显示注册表编辑器确认窗口,并不会在注册表本身没有相应的变化。
The registry file is located in the directory where the compiled executable is. foo.reg runs successfully when I run it from command line, but running the above program only shows the regedit confirmation window, and does no corresponding change in the registry itself.
我用开发-C ++写程序,我运行Windows XP 64位版的SP2。任何帮助将大大AP preciated。
I used Dev-C++ to write the program and I am running Windows XP x64 version SP2. Any help will be greatly appreciated.
推荐答案
系统(注册表编辑器/ s的foo.reg);
应该静静地导入它没有任何确认对话框。 请参考这里的 REGEDIT.EXE 的命令行选项。不过,我会怀疑有问题的注册表文件(foo.reg);检查它是否是正确的。此外它运行后,一定,如果你正在检查中, foo.reg
作出修改注册表中的正确的道路。
system("regedit /s foo.reg");
should import it silently without any confirmation dialogs. Refer here for command-line options of regedit.exe. However, I will be sceptical about the registry file (foo.reg) in question; check if it's correct. Also after running it, be sure if you're checking the right path in the registry which foo.reg
is made to amend.
在一个侧面说明,C标准库的系统()
功能文件stdlib.h
声明如此它应该是:
On a side note, system()
function of the C Standard Library is declared in stdlib.h
so it should be:
#include <stdlib.h>
int main()
{
system("regedit /s foo.reg");
return 0;
}
编辑:
我觉得导入已经获得成功;既然你已经提到,这是一个64位的XP机器,我认为这一改变会趴在 Wow6432Node
。例如。 HKEY_LOCAL_MACHINE \\ SOFTWARE \\ Wow6432Node
或 HKEY_CURRENT_USER \\ SOFTWARE \\ Wow6432Node
。因此,检查在 Wow6432Node
太。 看到这个帖子和的 MSDN 了解更多这方面的信息。
I think the import is already successful; since you've mentioned that it's a 64-bit XP machine, I think the change will be lying under the Wow6432Node
. E.g. HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node
or HKEY_CURRENT_USER\SOFTWARE\Wow6432Node
. So check under the Wow6432Node
too. See this post and MSDN for more information on this.
这篇关于使用C ++来导入注册表文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!