From 075bedc0da87a1bab1d62120f878cb3c344a7a51 Mon Sep 17 00:00:00 2001
From: Dijji <27084934+Dijji@users.noreply.github.com>
Date: Tue, 5 Nov 2019 13:06:10 +0000
Subject: [PATCH] Fix for issue #69
---
.gitignore | 19 +++++++++
AssociationManager/Extension.cs | 39 +++++++------------
AssociationManager/MainWindow.xaml.cs | 10 +++++
AssociationManager/Properties/AssemblyInfo.cs | 2 +-
.../Properties/AssemblyInfo.cs | 2 +-
TestDriverAssoc/Const.cs | 21 +++++++++-
TestDriverAssoc/TestCommandLine.cs | 7 ++++
7 files changed, 73 insertions(+), 27 deletions(-)
diff --git a/.gitignore b/.gitignore
index 734b44f..0b6e844 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,3 +9,22 @@
/GongSolutions.Wpf.DragDrop/obj
/TestDriver/obj
/TestDriverAssoc/obj
+/CommandLine/FileMeta.vcxproj.user
+/ContextMenuHandler/ContextMenuHandler.vcxproj.user
+/ipch
+/PropertyHandler/PropertyHandler.vcxproj.user
+/FileMetadata.sdf
+/FileMetadata.suo
+/FileMetadata.VC.db
+/FileMetadata.VC.VC.opendb
+/AssociationManager/bin/x64/Debug
+/AssociationMessages/bin/Debug
+/GongSolutions.Wpf.DragDrop/bin/Debug/NET35
+/TestDriver/.vs/TestDriver/v14
+/TestDriver/bin/x64/Debug
+/TestDriverAssoc/.vs/TestDriverAssoc/v14
+/TestDriverAssoc/bin/x64/Debug
+/AssociationMessages/bin/Release
+/CommandLineAssociationManager/bin/x64/Release
+/AssociationManager/bin/x64/Release
+/GongSolutions.Wpf.DragDrop/bin/Release/NET35
diff --git a/AssociationManager/Extension.cs b/AssociationManager/Extension.cs
index 25d6e9f..b458d6f 100644
--- a/AssociationManager/Extension.cs
+++ b/AssociationManager/Extension.cs
@@ -279,7 +279,8 @@ public void SetupHandlerForExtension(Profile selectedProfile, bool createMergedP
{
var temp = handler.GetValue(null);
handler.SetValue(null, OurPropertyHandlerGuid32);
- handler.SetValue(ChainedValueName, temp);
+ if (temp != null)
+ handler.SetValue(ChainedValueName, temp);
}
}
}
@@ -516,38 +517,28 @@ public void RemoveHandlerFromExtension()
using (RegistryKey handlers = RegistryExtensions.OpenBaseKey(RegistryHive.LocalMachine, RegistryExtensions.RegistryHiveType.X86).
OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\PropertySystem\PropertyHandlers", true))
{
- if (PropertyHandlerState == HandlerState.Ours)
+ bool delete = false;
+ using (RegistryKey handler = handlers.OpenSubKey(Name, true))
{
- bool delete = false;
- using (RegistryKey handler = handlers.OpenSubKey(Name, true))
+ if (handler != null)
{
- if (handler != null)
+ if (handler.GetValueNames().Contains(ChainedValueName))
+ {
+ var temp = handler.GetValue(ChainedValueName);
+ handler.SetValue(null, temp);
+ handler.DeleteValue(ChainedValueName);
+ }
+ else
{
// Only delete the sub key if it points to our handler
var temp = handler.GetValue(null) as string;
delete = (temp != null && temp == OurPropertyHandlerGuid32);
}
}
- // Delete needs to happen after we have released the registry key
- if (delete)
- handlers.DeleteSubKey(Name);
- }
- else // Chained
- {
- using (RegistryKey handler = handlers.OpenSubKey(Name, true))
- {
- if (handler != null)
- {
- // Allow for the case where the chained value exists but is empty
- if (handler.GetValueNames().Contains(ChainedValueName))
- {
- var temp = handler.GetValue(ChainedValueName);
- handler.SetValue(null, temp);
- handler.DeleteValue(ChainedValueName);
- }
- }
- }
}
+ // Delete needs to happen after we have released the registry key
+ if (delete)
+ handlers.DeleteSubKey(Name);
}
#endif
// Now, remove the main handler extension key, which is 32- or 64-bit, depending on how we were built
diff --git a/AssociationManager/MainWindow.xaml.cs b/AssociationManager/MainWindow.xaml.cs
index a61fe4a..41f3220 100644
--- a/AssociationManager/MainWindow.xaml.cs
+++ b/AssociationManager/MainWindow.xaml.cs
@@ -101,6 +101,11 @@ private void addHandler_Click(object sender, RoutedEventArgs e)
{
System.Windows.MessageBox.Show(ae.DisplayString, LocalizedMessages.ErrorHeader);
}
+ catch (Exception ex)
+ {
+ Clipboard.SetText(ex.ToString());
+ System.Windows.MessageBox.Show(ex.ToString(), LocalizedMessages.ErrorHeader);
+ }
}
private void removeHandler_Click(object sender, RoutedEventArgs e)
@@ -113,6 +118,11 @@ private void removeHandler_Click(object sender, RoutedEventArgs e)
{
System.Windows.MessageBox.Show(ae.DisplayString, LocalizedMessages.ErrorHeader);
}
+ catch (Exception ex)
+ {
+ Clipboard.SetText(ex.ToString());
+ System.Windows.MessageBox.Show(ex.ToString(), LocalizedMessages.ErrorHeader);
+ }
}
private void refresh_Click(object sender, RoutedEventArgs e)
diff --git a/AssociationManager/Properties/AssemblyInfo.cs b/AssociationManager/Properties/AssemblyInfo.cs
index 596a08e..19bdff4 100644
--- a/AssociationManager/Properties/AssemblyInfo.cs
+++ b/AssociationManager/Properties/AssemblyInfo.cs
@@ -51,4 +51,4 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.5.*")]
+[assembly: AssemblyVersion("1.6.*")]
diff --git a/CommandLineAssociationManager/Properties/AssemblyInfo.cs b/CommandLineAssociationManager/Properties/AssemblyInfo.cs
index 71bba28..f376722 100644
--- a/CommandLineAssociationManager/Properties/AssemblyInfo.cs
+++ b/CommandLineAssociationManager/Properties/AssemblyInfo.cs
@@ -32,4 +32,4 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.5.*")]
+[assembly: AssemblyVersion("1.6.*")]
diff --git a/TestDriverAssoc/Const.cs b/TestDriverAssoc/Const.cs
index 0b992a0..27cf205 100644
--- a/TestDriverAssoc/Const.cs
+++ b/TestDriverAssoc/Const.cs
@@ -29,6 +29,7 @@ class Const
#if x64
public static string OurPropertyHandlerGuid { get { return OurPropertyHandlerGuid64; } }
+ public static string OurPropertyHandlerGuid32bit { get { return OurPropertyHandlerGuid32; } }
public static string OurContextHandlerGuid { get { return OurContextHandlerGuid64; } }
#elif x86
public static string OurPropertyHandlerGuid { get { return OurPropertyHandlerGuid32; } }
@@ -142,8 +143,13 @@ class Const
{
PropertyHandler32 = OtherPropertyHandlerGuid,
};
+ // This is an initial state where there is a 64-bit property handler installed, but there is no 32-bit property handler
+ public static RegState V15InitialOther64 = new RegState
+ {
+ PropertyHandler = OtherPropertyHandlerGuid,
+ };
#endif
- // This is what we should find after we have added our handler in the above case
+ // This is what we should find after we have added our handler in the above 32 and 64-bit cases
public static RegState V15CustomTestOther32 = new RegState
{
SystemFullDetails = FullDetailsCustomProfileTest,
@@ -154,6 +160,19 @@ class Const
PropertyHandler = OurPropertyHandlerGuid,
#if x64
PropertyHandler32 = OtherPropertyHandlerGuid,
+#endif
+ };
+ public static RegState V15CustomTestOther64 = new RegState
+ {
+ SystemFullDetails = FullDetailsCustomProfileTest,
+ SystemPreviewDetails = PreviewDetailsCustomProfileTest,
+ SystemInfoTip = InfoTipCustomProfileTest,
+ SystemCustomProfile = "test",
+ SystemContextMenuHandler = OurContextHandlerGuid,
+ PropertyHandler = OurPropertyHandlerGuid,
+ ChainedPropertyHandler = OtherPropertyHandlerGuid,
+#if x64
+ PropertyHandler32 = OurPropertyHandlerGuid32bit,
#endif
};
public static RegState V15ExtendedBmp = new RegState
diff --git a/TestDriverAssoc/TestCommandLine.cs b/TestDriverAssoc/TestCommandLine.cs
index 6cc92ca..85e6bec 100644
--- a/TestDriverAssoc/TestCommandLine.cs
+++ b/TestDriverAssoc/TestCommandLine.cs
@@ -19,6 +19,10 @@ public enum WindowsErrorCode
ERROR_XML_PARSE_ERROR = 1465,
}
+ ///
+ ///
+ ///
+ ///
public static void Run(Object obj)
{
State state = (State)obj;
@@ -50,6 +54,7 @@ public static void Run(Object obj)
RoundTrip(state, "V15BuiltIn", ref Const.V15BuiltIn, ref pass);
RoundTrip(state, "V15Custom", ref Const.V15CustomTest, ref pass);
RoundTrip(state, "V15CustomOther32", ref Const.V15CustomTestOther32, ref pass);
+ RoundTrip(state, "V15CustomOther64", ref Const.V15CustomTestOther64, ref pass);
RoundTrip(state, "V15Extended", ref Const.V15ExtendedBmp, ref pass);
#if x64
RoundTrip(state, "V15InitialOther32", ref Const.V15InitialOther32, ref pass);
@@ -74,6 +79,7 @@ public static void Run(Object obj)
Remove(state, "Version 1.5 with custom profile", "V15Custom", ref Const.V15CustomTest, ref pass);
#if x64
Remove(state, "Version 1.5 with custom profile and existing 32 bit handler", "V15CustomOther32", ref Const.V15CustomTestOther32, ref pass, Const.V15InitialOther32);
+ Remove(state, "Version 1.5 with custom profile and existing 64 bit handler", "V15CustomOther64", ref Const.V15CustomTestOther64, ref pass, Const.V15InitialOther64);
#endif
Remove(state, "Version 1.5 with extended handler", "V15Extended", ref Const.V15ExtendedBmp, ref pass, Const.V15UnExtended);
Remove(state, "Version 1.5 with extended handler and CLSID settings", "V15ExtendedClsid", ref Const.V15ExtendedBmpClsid, ref pass, Const.V15UnExtendedClsid);
@@ -93,6 +99,7 @@ public static void Run(Object obj)
Add(state, "Extension does not exist, custom profile 'test'", "V15CustomTest", "-p=test -d=SavedState.xml", ref Const.V15CustomTest, ref pass);
#if x64
Add(state, "Extension does not exist, 32 bit handler does, custom profile 'test'", "V15CustomTestOther32", "-p=test -d=SavedState.xml", ref Const.V15CustomTestOther32, ref pass, Const.V15InitialOther32);
+ Add(state, "Extension does not exist, 64 bit handler does, custom profile 'test'", "V15CustomTestOther64", "-p=test -d=SavedState.xml", ref Const.V15CustomTestOther64, ref pass, Const.V15InitialOther64);
#endif
Common.ClearProfile();
Add(state, "Extend existing .bmp property handler", "V15ExtendedBmp", "-p=.bmp -d=SavedState.xml", ref Const.V15ExtendedBmp, ref pass, Const.V15UnExtended);