Just an implementation detail I noticed:
On 08/23/2011 11:45 AM, Hans Leidekker wrote:
+
+static UINT get_registered_local_package( const WCHAR *product, const WCHAR
*package, WCHAR *localfile )
+{
+MSIINSTALLCONTEXT context;
+HKEY product_key, props_key;
+WCHAR *registered_package = NULL, unsquashed[GUID_SIZE];
+UINT r = ERROR_FUNCTION_FAILED;
+
+r = msi_locate_product( product,&context );
+if (r != ERROR_SUCCESS)
+return r;
+
+r = MSIREG_OpenProductKey( product, NULL, context,&product_key, FALSE );
+if (r != ERROR_SUCCESS)
+return r;
+
+r = MSIREG_OpenInstallProps( product, context, NULL,&props_key, FALSE );
+if (r != ERROR_SUCCESS)
+{
+RegCloseKey( product_key );
+return r;
+}
+registered_package = msi_reg_get_val_str( product_key,
INSTALLPROPERTY_PACKAGECODEW );
+if (!registered_package)
+goto done;
+
+unsquash_guid( registered_package, unsquashed );
+if (!strcmpiW( package, unsquashed ))
+{
+WCHAR *filename = msi_reg_get_val_str( props_key,
INSTALLPROPERTY_LOCALPACKAGEW );
+strcpyW( localfile, filename );
+msi_free( filename );
+r = ERROR_SUCCESS;
+}
+done:
+msi_free( registered_package );
+RegCloseKey( props_key );
+RegCloseKey( product_key );
+return r;
+}
+
I'm confused about the last part of the function.
I think if the comparison between 'package' and 'unsquashed' fails, you
want to return an error,
but the return value 'r' will be ERROR_SUCCESS at that point, and isn't
updated.
HTH,
Joris