msi: Remove icons when the product is uninstalled.

This commit is contained in:
Hans Leidekker 2011-08-23 14:42:27 +02:00 committed by Alexandre Julliard
parent db6dbcf2a2
commit eb7ae99ddb
2 changed files with 43 additions and 0 deletions

View File

@ -4896,6 +4896,45 @@ static UINT ACTION_InstallExecute(MSIPACKAGE *package)
return execute_script(package,INSTALL_SCRIPT);
}
static UINT ITERATE_UnpublishIcon( MSIRECORD *row, LPVOID param )
{
MSIPACKAGE *package = param;
const WCHAR *icon = MSI_RecordGetString( row, 1 );
WCHAR *p, *icon_path;
if (!icon) return ERROR_SUCCESS;
if ((icon_path = msi_build_icon_path( package, icon )))
{
TRACE("removing icon file %s\n", debugstr_w(icon_path));
DeleteFileW( icon_path );
if ((p = strrchrW( icon_path, '\\' )))
{
*p = 0;
RemoveDirectoryW( icon_path );
}
msi_free( icon_path );
}
return ERROR_SUCCESS;
}
static UINT msi_unpublish_icons( MSIPACKAGE *package )
{
static const WCHAR query[]= {
'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ','`','I','c','o','n','`',0};
MSIQUERY *view;
UINT r;
r = MSI_DatabaseOpenViewW( package->db, query, &view );
if (r == ERROR_SUCCESS)
{
r = MSI_IterateRecords( view, NULL, ITERATE_UnpublishIcon, package );
msiobj_release( &view->hdr );
if (r != ERROR_SUCCESS)
return r;
}
return ERROR_SUCCESS;
}
static UINT msi_unpublish_product( MSIPACKAGE *package, const WCHAR *remove )
{
static const WCHAR szUpgradeCode[] = {'U','p','g','r','a','d','e','C','o','d','e',0};
@ -4948,6 +4987,8 @@ static UINT msi_unpublish_product( MSIPACKAGE *package, const WCHAR *remove )
}
TRACE("removing local package %s\n", debugstr_w(package->localfile));
package->delete_on_close = TRUE;
msi_unpublish_icons( package );
return ERROR_SUCCESS;
}

View File

@ -5980,6 +5980,7 @@ static void test_icon_table(void)
res = MsiInstallProductA(msifile, "REMOVE=ALL");
ok(res == ERROR_SUCCESS, "Failed to uninstall per-user\n");
ok(!file_exists(path), "Per-user icon file not removed (%s)\n", path);
/* system-wide */
res = MsiInstallProductA(msifile, "PUBLISH_PRODUCT=1 ALLUSERS=1");
@ -5994,6 +5995,7 @@ static void test_icon_table(void)
res = MsiInstallProductA(msifile, "REMOVE=ALL");
ok(res == ERROR_SUCCESS, "Failed to uninstall system-wide\n");
ok(!file_exists(path), "System-wide icon file not removed (%s)\n", path);
delete_pfmsitest_files();
DeleteFile(msifile);