[英]C++ extract .reg file to registry
Can anyone tell me please how to extract the data from a .reg file into the registry? 有谁能告诉我如何将.reg文件中的数据提取到注册表中?
I've tried: 我试过了:
system("regedit /s product.reg");
It doesn't work, I have also looked at various other questions on here but have had no joy and I have also trouble understanding them. 它不起作用,我也在这里看了各种其他问题,但没有任何喜悦,我也很难理解它们。
Can anyone shed any light or send me a link that has a good example please? 任何人都可以放弃任何亮点,或者给我一个有良好榜样的链接吗?
Thanks 谢谢
The following things applies to Windows Vista / Windows 7 and later version. 以下内容适用于Windows Vista / Windows 7及更高版本。
You won't be able to successfully execute regedit.exe unless your application is not running with Administrator privilege. 除非您的应用程序未以管理员权限运行,否则您将无法成功执行regedit.exe。
If you're using Visual Studio 2005/2008/2010, go to the property window of your project, expand the 'Linker' options, and select 'Manifest File'. 如果您使用的是Visual Studio 2005/2008/2010,请转到项目的属性窗口,展开“链接器”选项,然后选择“清单文件”。 Change UAC Execution Level to 'requireAministrator'.
将UAC执行级别更改为“requireAministrator”。 Save your project and rebuild your project.
保存项目并重建项目。
根据此 ,正确的命令是:
reg IMPORT <FileName>
system("product.reg")
should also work. 也应该工作。 This is akin to double-clicking the file.
这类似于双击文件。
Since you're on Windows anyway: ShellExecuteA("product.reg")
. 因为你还在Windows上:
ShellExecuteA("product.reg")
。 Unlike system
, this won't start a console window. 与
system
不同,这不会启动控制台窗口。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.