简体   繁体   中英

C++ extract .reg file to registry

Can anyone tell me please how to extract the data from a .reg file into the registry?

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.

You won't be able to successfully execute regedit.exe unless your application is not running with Administrator privilege.

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'. Change UAC Execution Level to '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") . Unlike system , this won't start a console window.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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