Natalie Carr
Natalie Carr

Reputation: 3797

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

Upvotes: 0

Views: 1600

Answers (4)

Rango
Rango

Reputation: 1105

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.

Upvotes: 2

MSalters
MSalters

Reputation: 179907

Since you're on Windows anyway: ShellExecuteA("product.reg"). Unlike system, this won't start a console window.

Upvotes: 0

gammay
gammay

Reputation: 6215

system("product.reg")

should also work. This is akin to double-clicking the file.

Upvotes: 0

Lyubomir Vasilev
Lyubomir Vasilev

Reputation: 3030

According to this, the correct command is:

reg IMPORT <FileName>

Upvotes: 0

Related Questions