Skip to content

Commit 80368c6

Browse files
committed
LocalDebugRegistryWriter now registers keys for x64 OS.
1 parent ba240ef commit 80368c6

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

Rubberduck.Deployment/Writers/LocalDebugRegistryWriter.cs

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public class LocalDebugRegistryWriter : IRegistryWriter
1313
{
1414
public string Write(IOrderedEnumerable<RegistryEntry> entries)
1515
{
16+
//System.Diagnostics.Debugger.Launch(); //uncomment if need to debug
1617
var sb = new StringBuilder("Windows Registry Editor Version 5.00" + Environment.NewLine + Environment.NewLine);
1718
var distinctKeys = new List<string>();
1819

@@ -30,14 +31,16 @@ public string Write(IOrderedEnumerable<RegistryEntry> entries)
3031
throw new InvalidOperationException("Unexpected registry entry: " + entry.Key);
3132
}
3233

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)
3735
{
38-
key.SetValue(entry.Name, value);
36+
MakeRegistryEntries(entry, RegistryKey.OpenBaseKey(RegistryHive.CurrentUser, RegistryView.Registry32));
37+
MakeRegistryEntries(entry, RegistryKey.OpenBaseKey(RegistryHive.CurrentUser, RegistryView.Registry64));
3938
}
40-
39+
else
40+
{
41+
MakeRegistryEntries(entry, RegistryKey.OpenBaseKey(RegistryHive.CurrentUser, RegistryView.Registry32));
42+
}
43+
4144
if (!distinctKeys.Contains(entry.Key))
4245
{
4346
distinctKeys.Add(entry.Key);
@@ -50,7 +53,19 @@ public string Write(IOrderedEnumerable<RegistryEntry> entries)
5053
sb.AppendLine("[-HKEY_CURRENT_USER\\" + key + "]" + Environment.NewLine);
5154
}
5255

53-
return sb.ToString();
56+
return sb.ToString(); //FIXME: this is not printing reg redirections.
57+
}
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+
}
5469
}
5570

5671
//Cache the string so we call the AssemblyDirectory only once

0 commit comments

Comments
 (0)