[UPDATE] [programs/uninstaller] Check HKCU for uninstall entries too

James Hawkins truiken at gmail.com
Thu Apr 19 15:42:35 CDT 2007


On 4/19/07, Tom Spear <speeddymon at gmail.com> wrote:
> Apparently the last patch had multiple patches in the file because I
> didnt delete it before creating the new one..
>
> So here we go again.
>
> Check HKCU as well as HKLM for uninstall entries, using a for loop
>

@@ -69,7 +69,7 @@
 /**
  * Used to output program list when used with --list
  */
-static void ListUninstallPrograms(void)
+static void ListUninstallPrograms()

The parameter list was correct as is.  If a function takes no
parameters, the correct list is 'void'.  Don't change parts of the
code that don't have to do with your patch, especially when you don't
know what you're changing.

     if (i < numentries)
-        UninstallProgram();
+        for (x=0; x<2; x++)
+            UninstallProgram(rootkey);

Why are you calling UninstallProgram twice with the same key?  Besides
that, using magic numbers (2) is bad coding.

+    HKEY keys[2];
+    keys[0] = HKEY_CURRENT_USER;
+    keys[1] = HKEY_LOCAL_MACHINE;

HKEY keys[] = { HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE };

+	for (x=0; x<2; x++)

You're hardcoding this value to 2, which is another bad magic number.
What if, hypothetically, more root keys are added to the list?

for (x = 0; x < sizeof(keys); x++)

+    rootkey[0] = HKEY_CURRENT_USER;
+    rootkey[1] = HKEY_LOCAL_MACHINE;

Same thing as above.

+        sizeOfSubKeyName = 255;

What is 255?

+    HKEY rootkey[2];
+    rootkey[0] = HKEY_CURRENT_USER;
+    rootkey[1] = HKEY_LOCAL_MACHINE;

Same.

+                        /* FIXME: UninstallProgram should figure out
which root key to uninstall
+                         * from, as opposed to just going with the
first value in rootkey.  The
+                         * entry gets removed this way as well, but
it is not apparent by this code.
+                         */
+                        UninstallProgram(*rootkey);

What is the point of adding rootkey if you're not going to use it?
UninstallProgram(HKEY_X) is a lot shorter.  The point is, don't add
something until you're going to use it.  On top of that, this new code
is basically UninstallProgram(HKEY_CURRENT_USER) when the original
code was (parameter added for convenience)
UninstallProgram(HKEY_LOCAL_MACHINE).  That's not right.

-- 
James Hawkins



More information about the wine-devel mailing list