Skip to content

Commit

Permalink
Fix for issue #69
Browse files Browse the repository at this point in the history
  • Loading branch information
Dijji committed Nov 5, 2019
1 parent 4b8fed2 commit 075bedc
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 27 deletions.
19 changes: 19 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
39 changes: 15 additions & 24 deletions AssociationManager/Extension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Expand Down Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions AssociationManager/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion AssociationManager/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.*")]
2 changes: 1 addition & 1 deletion CommandLineAssociationManager/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.*")]
21 changes: 20 additions & 1 deletion TestDriverAssoc/Const.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; } }
Expand Down Expand Up @@ -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,
Expand All @@ -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
Expand Down
7 changes: 7 additions & 0 deletions TestDriverAssoc/TestCommandLine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ public enum WindowsErrorCode
ERROR_XML_PARSE_ERROR = 1465,
}

/// <summary>
///
/// </summary>
/// <param name="obj"></param>
public static void Run(Object obj)
{
State state = (State)obj;
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit 075bedc

Please sign in to comment.