Skip to content

Commit 075bedc

Browse files
committed
Fix for issue #69
1 parent 4b8fed2 commit 075bedc

File tree

7 files changed

+73
-27
lines changed

7 files changed

+73
-27
lines changed

.gitignore

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,22 @@
99
/GongSolutions.Wpf.DragDrop/obj
1010
/TestDriver/obj
1111
/TestDriverAssoc/obj
12+
/CommandLine/FileMeta.vcxproj.user
13+
/ContextMenuHandler/ContextMenuHandler.vcxproj.user
14+
/ipch
15+
/PropertyHandler/PropertyHandler.vcxproj.user
16+
/FileMetadata.sdf
17+
/FileMetadata.suo
18+
/FileMetadata.VC.db
19+
/FileMetadata.VC.VC.opendb
20+
/AssociationManager/bin/x64/Debug
21+
/AssociationMessages/bin/Debug
22+
/GongSolutions.Wpf.DragDrop/bin/Debug/NET35
23+
/TestDriver/.vs/TestDriver/v14
24+
/TestDriver/bin/x64/Debug
25+
/TestDriverAssoc/.vs/TestDriverAssoc/v14
26+
/TestDriverAssoc/bin/x64/Debug
27+
/AssociationMessages/bin/Release
28+
/CommandLineAssociationManager/bin/x64/Release
29+
/AssociationManager/bin/x64/Release
30+
/GongSolutions.Wpf.DragDrop/bin/Release/NET35

AssociationManager/Extension.cs

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,8 @@ public void SetupHandlerForExtension(Profile selectedProfile, bool createMergedP
279279
{
280280
var temp = handler.GetValue(null);
281281
handler.SetValue(null, OurPropertyHandlerGuid32);
282-
handler.SetValue(ChainedValueName, temp);
282+
if (temp != null)
283+
handler.SetValue(ChainedValueName, temp);
283284
}
284285
}
285286
}
@@ -516,38 +517,28 @@ public void RemoveHandlerFromExtension()
516517
using (RegistryKey handlers = RegistryExtensions.OpenBaseKey(RegistryHive.LocalMachine, RegistryExtensions.RegistryHiveType.X86).
517518
OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\PropertySystem\PropertyHandlers", true))
518519
{
519-
if (PropertyHandlerState == HandlerState.Ours)
520+
bool delete = false;
521+
using (RegistryKey handler = handlers.OpenSubKey(Name, true))
520522
{
521-
bool delete = false;
522-
using (RegistryKey handler = handlers.OpenSubKey(Name, true))
523+
if (handler != null)
523524
{
524-
if (handler != null)
525+
if (handler.GetValueNames().Contains(ChainedValueName))
526+
{
527+
var temp = handler.GetValue(ChainedValueName);
528+
handler.SetValue(null, temp);
529+
handler.DeleteValue(ChainedValueName);
530+
}
531+
else
525532
{
526533
// Only delete the sub key if it points to our handler
527534
var temp = handler.GetValue(null) as string;
528535
delete = (temp != null && temp == OurPropertyHandlerGuid32);
529536
}
530537
}
531-
// Delete needs to happen after we have released the registry key
532-
if (delete)
533-
handlers.DeleteSubKey(Name);
534-
}
535-
else // Chained
536-
{
537-
using (RegistryKey handler = handlers.OpenSubKey(Name, true))
538-
{
539-
if (handler != null)
540-
{
541-
// Allow for the case where the chained value exists but is empty
542-
if (handler.GetValueNames().Contains(ChainedValueName))
543-
{
544-
var temp = handler.GetValue(ChainedValueName);
545-
handler.SetValue(null, temp);
546-
handler.DeleteValue(ChainedValueName);
547-
}
548-
}
549-
}
550538
}
539+
// Delete needs to happen after we have released the registry key
540+
if (delete)
541+
handlers.DeleteSubKey(Name);
551542
}
552543
#endif
553544
// Now, remove the main handler extension key, which is 32- or 64-bit, depending on how we were built

AssociationManager/MainWindow.xaml.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,11 @@ private void addHandler_Click(object sender, RoutedEventArgs e)
101101
{
102102
System.Windows.MessageBox.Show(ae.DisplayString, LocalizedMessages.ErrorHeader);
103103
}
104+
catch (Exception ex)
105+
{
106+
Clipboard.SetText(ex.ToString());
107+
System.Windows.MessageBox.Show(ex.ToString(), LocalizedMessages.ErrorHeader);
108+
}
104109
}
105110

106111
private void removeHandler_Click(object sender, RoutedEventArgs e)
@@ -113,6 +118,11 @@ private void removeHandler_Click(object sender, RoutedEventArgs e)
113118
{
114119
System.Windows.MessageBox.Show(ae.DisplayString, LocalizedMessages.ErrorHeader);
115120
}
121+
catch (Exception ex)
122+
{
123+
Clipboard.SetText(ex.ToString());
124+
System.Windows.MessageBox.Show(ex.ToString(), LocalizedMessages.ErrorHeader);
125+
}
116126
}
117127

118128
private void refresh_Click(object sender, RoutedEventArgs e)

AssociationManager/Properties/AssemblyInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,4 @@
5151
// You can specify all the values or you can default the Build and Revision Numbers
5252
// by using the '*' as shown below:
5353
// [assembly: AssemblyVersion("1.0.*")]
54-
[assembly: AssemblyVersion("1.5.*")]
54+
[assembly: AssemblyVersion("1.6.*")]

CommandLineAssociationManager/Properties/AssemblyInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("1.5.*")]
35+
[assembly: AssemblyVersion("1.6.*")]

TestDriverAssoc/Const.cs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class Const
2929

3030
#if x64
3131
public static string OurPropertyHandlerGuid { get { return OurPropertyHandlerGuid64; } }
32+
public static string OurPropertyHandlerGuid32bit { get { return OurPropertyHandlerGuid32; } }
3233
public static string OurContextHandlerGuid { get { return OurContextHandlerGuid64; } }
3334
#elif x86
3435
public static string OurPropertyHandlerGuid { get { return OurPropertyHandlerGuid32; } }
@@ -142,8 +143,13 @@ class Const
142143
{
143144
PropertyHandler32 = OtherPropertyHandlerGuid,
144145
};
146+
// This is an initial state where there is a 64-bit property handler installed, but there is no 32-bit property handler
147+
public static RegState V15InitialOther64 = new RegState
148+
{
149+
PropertyHandler = OtherPropertyHandlerGuid,
150+
};
145151
#endif
146-
// This is what we should find after we have added our handler in the above case
152+
// This is what we should find after we have added our handler in the above 32 and 64-bit cases
147153
public static RegState V15CustomTestOther32 = new RegState
148154
{
149155
SystemFullDetails = FullDetailsCustomProfileTest,
@@ -154,6 +160,19 @@ class Const
154160
PropertyHandler = OurPropertyHandlerGuid,
155161
#if x64
156162
PropertyHandler32 = OtherPropertyHandlerGuid,
163+
#endif
164+
};
165+
public static RegState V15CustomTestOther64 = new RegState
166+
{
167+
SystemFullDetails = FullDetailsCustomProfileTest,
168+
SystemPreviewDetails = PreviewDetailsCustomProfileTest,
169+
SystemInfoTip = InfoTipCustomProfileTest,
170+
SystemCustomProfile = "test",
171+
SystemContextMenuHandler = OurContextHandlerGuid,
172+
PropertyHandler = OurPropertyHandlerGuid,
173+
ChainedPropertyHandler = OtherPropertyHandlerGuid,
174+
#if x64
175+
PropertyHandler32 = OurPropertyHandlerGuid32bit,
157176
#endif
158177
};
159178
public static RegState V15ExtendedBmp = new RegState

TestDriverAssoc/TestCommandLine.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ public enum WindowsErrorCode
1919
ERROR_XML_PARSE_ERROR = 1465,
2020
}
2121

22+
/// <summary>
23+
///
24+
/// </summary>
25+
/// <param name="obj"></param>
2226
public static void Run(Object obj)
2327
{
2428
State state = (State)obj;
@@ -50,6 +54,7 @@ public static void Run(Object obj)
5054
RoundTrip(state, "V15BuiltIn", ref Const.V15BuiltIn, ref pass);
5155
RoundTrip(state, "V15Custom", ref Const.V15CustomTest, ref pass);
5256
RoundTrip(state, "V15CustomOther32", ref Const.V15CustomTestOther32, ref pass);
57+
RoundTrip(state, "V15CustomOther64", ref Const.V15CustomTestOther64, ref pass);
5358
RoundTrip(state, "V15Extended", ref Const.V15ExtendedBmp, ref pass);
5459
#if x64
5560
RoundTrip(state, "V15InitialOther32", ref Const.V15InitialOther32, ref pass);
@@ -74,6 +79,7 @@ public static void Run(Object obj)
7479
Remove(state, "Version 1.5 with custom profile", "V15Custom", ref Const.V15CustomTest, ref pass);
7580
#if x64
7681
Remove(state, "Version 1.5 with custom profile and existing 32 bit handler", "V15CustomOther32", ref Const.V15CustomTestOther32, ref pass, Const.V15InitialOther32);
82+
Remove(state, "Version 1.5 with custom profile and existing 64 bit handler", "V15CustomOther64", ref Const.V15CustomTestOther64, ref pass, Const.V15InitialOther64);
7783
#endif
7884
Remove(state, "Version 1.5 with extended handler", "V15Extended", ref Const.V15ExtendedBmp, ref pass, Const.V15UnExtended);
7985
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)
9399
Add(state, "Extension does not exist, custom profile 'test'", "V15CustomTest", "-p=test -d=SavedState.xml", ref Const.V15CustomTest, ref pass);
94100
#if x64
95101
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);
102+
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);
96103
#endif
97104
Common.ClearProfile();
98105
Add(state, "Extend existing .bmp property handler", "V15ExtendedBmp", "-p=.bmp -d=SavedState.xml", ref Const.V15ExtendedBmp, ref pass, Const.V15UnExtended);

0 commit comments

Comments
 (0)