@@ -652,11 +652,15 @@ private bool CompareKeys(RegistryView registryView, RegistryStateElement registr
652652 private bool CompareValues ( object value , RegistryView registryView , RegistryStateElement registryStateElement , RegistryStateElement activeRegistryStateElement , string activeCurrentUser = null , bool activeAdministrator = true ) {
653653 // caller needs to decide what to do if value is null
654654 if ( ! ( value is string comparableValue ) ) {
655- throw new ArgumentNullException ( "The comparableValueString is null." ) ;
655+ throw new ArgumentNullException ( "The comparableValue is null." ) ;
656656 }
657657
658658 if ( registryStateElement == null ) {
659- throw new ArgumentNullException ( "The registryStateElement is null." ) ;
659+ registryStateElement = activeRegistryStateElement ;
660+
661+ if ( registryStateElement == null ) {
662+ throw new ArgumentNullException ( "The registryStateElement is null." ) ;
663+ }
660664 }
661665
662666 RegistryValueKind ? valueKind = null ;
@@ -713,20 +717,21 @@ private bool CompareValues(object value, RegistryView registryView, RegistryStat
713717 }
714718 }
715719
716- if ( activeRegistryStateElement != null ) {
720+ if ( activeRegistryStateElement != null
721+ && activeRegistryStateElement != registryStateElement ) {
717722 // get value before
718723 comparableRegistryStateElementValue = activeRegistryStateElement . Value ;
719724
720725 // if value existed before
721726 if ( comparableRegistryStateElementValue != null ) {
722727 // value kind before also matters
723728 if ( valueKind == activeRegistryStateElement . ValueKind ) {
724- // check value matches
729+ // check value matches current value
725730 if ( comparableValue . Equals ( comparableRegistryStateElementValue , StringComparison . Ordinal ) ) {
726731 return true ;
727732 }
728733
729- // check if it matches as a path
734+ // for ActiveX: check if it matches as a path
730735 try {
731736 if ( ComparePaths ( comparableValue , comparableRegistryStateElementValue ) ) {
732737 return true ;
@@ -1033,6 +1038,7 @@ public override void Activate(string templateName) {
10331038 if ( registryStateElement . Type == TYPE . KEY ) {
10341039 // we create a key
10351040 activeRegistryStateElement . Type = TYPE . KEY ;
1041+ activeRegistryStateElement . Value = null ;
10361042
10371043 try {
10381044 activeRegistryStateElement . _Deleted = TestKeyDeletedInRegistryView ( keyName , registryView ) ;
@@ -1093,10 +1099,12 @@ public override void Activate(string templateName) {
10931099 // or, we edit a value that exists
10941100 activeRegistryStateElement . Type = TYPE . VALUE ;
10951101 activeRegistryStateElement . Value = value ;
1102+ activeRegistryStateElement . _Deleted = null ;
10961103 } else {
10971104 // we create a value
10981105 // the value, and the key it belonged to, does not exist
10991106 activeRegistryStateElement . Type = TYPE . KEY ;
1107+ activeRegistryStateElement . Value = null ;
11001108 activeRegistryStateElement . _Deleted = keyDeleted ;
11011109 }
11021110 }
0 commit comments