What is the best way to programmatically merge a .reg file into a registry? This is for unit testing; A .reg file is a test artifact that will be added and then deleted at the beginning and end of testing.
Or, if there is a better way to unit test to the registry ...
You can delete registry keys using a REG file, although I'm not sure how well it is documented. Here's how:
REGEDIT4 [-HKEY_CURRENT_USER\Software\<otherpath>]
-before the key name indicates Regeditthat you want to delete the key.
-
Regedit
To start it silently, type:
regedit /s "myfile.reg"
, reg ( . ). , , , .
C: > reg/?
REG [ ]
[QUERY | | | | | | | | | | | FLAGS]
: ( REG COMPARE)
0 - 1 -
:
REG ADD/? REG DELETE/? []
, .
, .reg regedit.exe Windows.
regedit.exe
, regedit.exe "mytest.reg". , , .
regedit.exe "mytest.reg"
Win32 API ShellExecute() ShellExecuteEx(). "", .reg. , .
, , . , Test-Driven Development, , , . , ?
When I find myself asking questions such as this, I look for ways to separate the code that I write from the dependency. Separate your registry reading from the complexity you want to test.