Skip to content

Commit 7d9963e

Browse files
committed
Merge branch 'rubberduck-vba/next' into next
2 parents efaabe8 + eadfc53 commit 7d9963e

File tree

2 files changed

+30
-7
lines changed

2 files changed

+30
-7
lines changed

Rubberduck.Deployment/BuildRegistryScript.ps1

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,17 @@ try
9595
if (Test-Path -Path $regFile -PathType Leaf)
9696
{
9797
$datetime = Get-Date;
98-
& reg.exe import $regFile;
98+
if ([Environment]::Is64BitOperatingSystem)
99+
{
100+
& reg.exe import $regFile /reg:32;
101+
& reg.exe import $regFile /reg:64;
102+
}
103+
else
104+
{
105+
& reg.exe import $regFile;
106+
}
99107
& reg.exe import ($dir + "\RubberduckAddinRegistry.reg");
100-
Move-Item -Path $regFile -Destination ($regFile + ".imported_" + $datetime.ToUniversalTime().ToString("yyyyMMddhhmmss") + ".txt" )
108+
Move-Item -Path $regFile -Destination ($regFile + ".imported_" + $datetime.ToUniversalTime().ToString("yyyyMMddHHmmss") + ".txt" )
101109
}
102110
}
103111
else

Rubberduck.Deployment/Writers/LocalDebugRegistryWriter.cs

Lines changed: 20 additions & 5 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,12 +31,14 @@ 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)
35+
{
36+
MakeRegistryEntries(entry, RegistryKey.OpenBaseKey(RegistryHive.CurrentUser, RegistryView.Registry32));
37+
MakeRegistryEntries(entry, RegistryKey.OpenBaseKey(RegistryHive.CurrentUser, RegistryView.Registry64));
38+
}
39+
else
3740
{
38-
key.SetValue(entry.Name, value);
41+
MakeRegistryEntries(entry, Registry.CurrentUser);
3942
}
4043

4144
if (!distinctKeys.Contains(entry.Key))
@@ -53,6 +56,18 @@ public string Write(IOrderedEnumerable<RegistryEntry> entries)
5356
return sb.ToString();
5457
}
5558

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+
5671
//Cache the string so we call the AssemblyDirectory only once
5772
private string _currentPath;
5873
private string ReplacePlaceholder(string value, Bitness bitness)

0 commit comments

Comments
 (0)