DWORD WINAPI UninstallerThread(LPVOID data) { // also kill the original uninstaller, if it's just spawned // a DELETE_ON_CLOSE copy from the temp directory WCHAR *exePath = GetUninstallerPath(); if (!path::IsSame(exePath, GetOwnPath())) KillProcess(exePath, TRUE); free(exePath); if (!RemoveUninstallerRegistryInfo(HKEY_LOCAL_MACHINE) && !RemoveUninstallerRegistryInfo(HKEY_CURRENT_USER)) { NotifyFailed(L"Failed to delete uninstaller registry keys"); } if (!RemoveShortcut(true) && !RemoveShortcut(false)) NotifyFailed(L"Couldn't remove the shortcut"); UninstallBrowserPlugin(); UninstallPdfFilter(); UninstallPdfPreviewer(); RemoveOwnRegistryKeys(); if (!RemoveInstalledFiles()) NotifyFailed(L"Couldn't remove installation directory"); // always succeed, even for partial uninstallations gGlobalData.success = true; if (!gGlobalData.silent) PostMessage(gHwndFrame, WM_APP_INSTALLATION_FINISHED, 0, 0); return 0; }
static bool WriteUninstallerRegistryInfo(HKEY hkey) { bool ok = true; ScopedMem<WCHAR> installedExePath(GetInstalledExePath()); ScopedMem<WCHAR> installDate(GetInstallDate()); ScopedMem<WCHAR> installDir(path::GetDir(installedExePath)); ScopedMem<WCHAR> uninstallCmdLine(str::Format(L"\"%s\"", ScopedMem<WCHAR>(GetUninstallerPath()))); ok &= WriteRegStr(hkey, REG_PATH_UNINST, DISPLAY_ICON, installedExePath); ok &= WriteRegStr(hkey, REG_PATH_UNINST, DISPLAY_NAME, APP_NAME_STR); ok &= WriteRegStr(hkey, REG_PATH_UNINST, DISPLAY_VERSION, CURR_VERSION_STR); // Windows XP doesn't allow to view the version number at a glance, // so include it in the DisplayName if (!IsVistaOrGreater()) ok &= WriteRegStr(hkey, REG_PATH_UNINST, DISPLAY_NAME, APP_NAME_STR L" " CURR_VERSION_STR); DWORD size = GetDirSize(gGlobalData.installDir) / 1024; ok &= WriteRegDWORD(hkey, REG_PATH_UNINST, ESTIMATED_SIZE, size); ok &= WriteRegStr(hkey, REG_PATH_UNINST, INSTALL_DATE, installDate); ok &= WriteRegStr(hkey, REG_PATH_UNINST, INSTALL_LOCATION, installDir); ok &= WriteRegDWORD(hkey, REG_PATH_UNINST, NO_MODIFY, 1); ok &= WriteRegDWORD(hkey, REG_PATH_UNINST, NO_REPAIR, 1); ok &= WriteRegStr(hkey, REG_PATH_UNINST, PUBLISHER, TEXT(PUBLISHER_STR)); ok &= WriteRegStr(hkey, REG_PATH_UNINST, UNINSTALL_STRING, uninstallCmdLine); ok &= WriteRegStr(hkey, REG_PATH_UNINST, URL_INFO_ABOUT, L"http://www.sumatrapdfreader.org/"); ok &= WriteRegStr(hkey, REG_PATH_UNINST, URL_UPDATE_INFO, L"http://www.sumatrapdfreader.org/news.html"); return ok; }
static bool WriteUninstallerRegistryInfo(HKEY hkey) { bool success = true; ScopedMem<WCHAR> uninstallerPath(GetUninstallerPath()); ScopedMem<WCHAR> installedExePath(GetInstalledExePath()); ScopedMem<WCHAR> installDate(GetInstallDate()); ScopedMem<WCHAR> installDir(path::GetDir(installedExePath)); success &= WriteRegStr(hkey, REG_PATH_UNINST, DISPLAY_ICON, installedExePath); success &= WriteRegStr(hkey, REG_PATH_UNINST, DISPLAY_NAME, TAPP); success &= WriteRegStr(hkey, REG_PATH_UNINST, DISPLAY_VERSION, CURR_VERSION_STR); // Windows XP doesn't allow to view the version number at a glance, // so include it in the DisplayName if (!IsVistaOrGreater()) success &= WriteRegStr(hkey, REG_PATH_UNINST, DISPLAY_NAME, TAPP L" " CURR_VERSION_STR); DWORD size = GetDirSize(gGlobalData.installDir) / 1024; success &= WriteRegDWORD(hkey, REG_PATH_UNINST, ESTIMATED_SIZE, size); success &= WriteRegStr(hkey, REG_PATH_UNINST, INSTALL_DATE, installDate); success &= WriteRegStr(hkey, REG_PATH_UNINST, INSTALL_LOCATION, installDir); success &= WriteRegDWORD(hkey, REG_PATH_UNINST, NO_MODIFY, 1); success &= WriteRegDWORD(hkey, REG_PATH_UNINST, NO_REPAIR, 1); success &= WriteRegStr(hkey, REG_PATH_UNINST, PUBLISHER, TEXT(PUBLISHER_STR)); success &= WriteRegStr(hkey, REG_PATH_UNINST, UNINSTALL_STRING, uninstallerPath); success &= WriteRegStr(hkey, REG_PATH_UNINST, URL_INFO_ABOUT, L"http://blog.kowalczyk.info/software/sumatrapdf/"); success &= WriteRegStr(hkey, REG_PATH_UNINST, URL_UPDATE_INFO, L"http://blog.kowalczyk.info/software/sumatrapdf/news.html"); return success; }