Log("DESTINATION: %s", DestinationKeyName);
Log("SOURCE: %s", SourceKeyName);
+ Error = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
+ SourceKeyName,
+ 0,
+ KEY_ALL_ACCESS,
+ &SourceKey);
+ if (Error != ERROR_SUCCESS) {
+ SetLastError(Error);
+ goto fail1;
+ }
+
Error = RegCreateKeyEx(HKEY_LOCAL_MACHINE,
DestinationKeyName,
0,
NULL,
&DestinationKey,
NULL);
- if (Error != ERROR_SUCCESS) {
- SetLastError(Error);
- goto fail1;
- }
-
- Error = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
- SourceKeyName,
- 0,
- KEY_ALL_ACCESS,
- &SourceKey);
if (Error != ERROR_SUCCESS) {
SetLastError(Error);
goto fail2;
}
-
+
CopyKeyValues(DestinationKey, SourceKey);
- RegCloseKey(SourceKey);
RegCloseKey(DestinationKey);
+ RegCloseKey(SourceKey);
Log("<====");
fail2:
Log("fail2");
- RegCloseKey(DestinationKey);
+ RegCloseKey(SourceKey);
fail1:
Error = GetLastError();
Log("DESTINATION: %s\\%s", DestinationKeyName, DestinationValueName);
Log("SOURCE: %s\\%s", SourceKeyName, SourceValueName);
+ Error = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
+ SourceKeyName,
+ 0,
+ KEY_ALL_ACCESS,
+ &SourceKey);
+ if (Error != ERROR_SUCCESS) {
+ if (Error == ERROR_FILE_NOT_FOUND)
+ goto done;
+
+ SetLastError(Error);
+ goto fail1;
+ }
+
Error = RegCreateKeyEx(HKEY_LOCAL_MACHINE,
DestinationKeyName,
0,
NULL,
&DestinationKey,
NULL);
- if (Error != ERROR_SUCCESS) {
- SetLastError(Error);
- goto fail1;
- }
-
- Error = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
- SourceKeyName,
- 0,
- KEY_ALL_ACCESS,
- &SourceKey);
if (Error != ERROR_SUCCESS) {
SetLastError(Error);
goto fail2;
free(Value);
free(Name);
- RegCloseKey(SourceKey);
RegCloseKey(DestinationKey);
+ RegCloseKey(SourceKey);
done:
fail3:
Log("fail3");
- RegCloseKey(SourceKey);
+ RegCloseKey(DestinationKey);
fail2:
Log("fail2");
- RegCloseKey(DestinationKey);
+ RegCloseKey(SourceKey);
fail1:
Error = GetLastError();