@@ -13,6 +13,7 @@ public class LocalDebugRegistryWriter : IRegistryWriter
13
13
{
14
14
public string Write ( IOrderedEnumerable < RegistryEntry > entries )
15
15
{
16
+ //System.Diagnostics.Debugger.Launch(); //uncomment if need to debug
16
17
var sb = new StringBuilder ( "Windows Registry Editor Version 5.00" + Environment . NewLine + Environment . NewLine ) ;
17
18
var distinctKeys = new List < string > ( ) ;
18
19
@@ -30,12 +31,14 @@ public string Write(IOrderedEnumerable<RegistryEntry> entries)
30
31
throw new InvalidOperationException ( "Unexpected registry entry: " + entry . Key ) ;
31
32
}
32
33
33
- var value = ReplacePlaceholder ( entry . Value , entry . Bitness ) ;
34
-
35
- var key = Registry . CurrentUser . CreateSubKey ( entry . Key ) ;
36
- if ( ! ( string . IsNullOrWhiteSpace ( entry . Name ) && string . IsNullOrWhiteSpace ( value ) ) )
34
+ if ( Environment . Is64BitOperatingSystem )
35
+ {
36
+ MakeRegistryEntries ( entry , RegistryKey . OpenBaseKey ( RegistryHive . CurrentUser , RegistryView . Registry32 ) ) ;
37
+ MakeRegistryEntries ( entry , RegistryKey . OpenBaseKey ( RegistryHive . CurrentUser , RegistryView . Registry64 ) ) ;
38
+ }
39
+ else
37
40
{
38
- key . SetValue ( entry . Name , value ) ;
41
+ MakeRegistryEntries ( entry , Registry . CurrentUser ) ;
39
42
}
40
43
41
44
if ( ! distinctKeys . Contains ( entry . Key ) )
@@ -53,6 +56,18 @@ public string Write(IOrderedEnumerable<RegistryEntry> entries)
53
56
return sb . ToString ( ) ;
54
57
}
55
58
59
+ private void MakeRegistryEntries ( RegistryEntry entry , RegistryKey hKey )
60
+ {
61
+ var key = hKey . CreateSubKey ( entry . Key ) ;
62
+
63
+ var value = ReplacePlaceholder ( entry . Value , entry . Bitness ) ;
64
+
65
+ if ( ! ( string . IsNullOrWhiteSpace ( entry . Name ) && string . IsNullOrWhiteSpace ( value ) ) )
66
+ {
67
+ key . SetValue ( entry . Name , value ) ;
68
+ }
69
+ }
70
+
56
71
//Cache the string so we call the AssemblyDirectory only once
57
72
private string _currentPath ;
58
73
private string ReplacePlaceholder ( string value , Bitness bitness )
0 commit comments