Beispiel #1
0
        installer::error write_to_uninstall_key()
        {
            CAtlString uninstall_command = (LPCWSTR)(QString("\"") + get_installer_exe().replace('/', '\\') + "\"" + " -uninstall").utf16();
            CAtlString display_name = (LPCWSTR)(get_product_display_name() + " (" + QT_TRANSLATE_NOOP("write_to_uninstall", "version") + " " + VERSION_INFO_STR + ")").utf16();
            CAtlString exe = (LPCWSTR) get_icq_exe().replace('/', '\\').utf16();
            CAtlString install_path = (LPCWSTR) get_install_folder().replace('/', '\\').utf16();

            CRegKey key_current_version;
            if (ERROR_SUCCESS != key_current_version.Open(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion"))
                return installer::error(errorcode::open_registry_key, "open registry key: Software\\Microsoft\\Windows\\CurrentVersion");

            CRegKey key_uninstall;
            if (ERROR_SUCCESS != key_uninstall.Create(key_current_version, L"Uninstall"))
                return installer::error(errorcode::create_registry_key, QString("create registry key: Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall"));

            CRegKey key_icq;
            if (ERROR_SUCCESS != key_icq.Create(key_uninstall, L"icq.desktop"))
                return installer::error(errorcode::create_registry_key, QString("create registry key: Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\icq.desktop"));

            QString version = VERSION_INFO_STR;
            QString major_version, minor_version;
            QStringList version_list = version.split('.');
            if (version_list.size() > 2)
            {
                major_version = version_list[0];
                minor_version = version_list[1];
            }


            if (
                ERROR_SUCCESS != key_icq.SetStringValue(L"DisplayName", display_name) ||
                ERROR_SUCCESS != key_icq.SetStringValue(L"DisplayIcon", CAtlString(L"\"") + exe + L"\"") ||
                ERROR_SUCCESS != key_icq.SetStringValue(L"DisplayVersion", (LPCWSTR) version.utf16()) ||
                ERROR_SUCCESS != key_icq.SetStringValue(L"VersionMajor", (LPCWSTR) major_version.utf16()) ||
                ERROR_SUCCESS != key_icq.SetStringValue(L"VersionMinor", (LPCWSTR) minor_version.utf16()) ||
                ERROR_SUCCESS != key_icq.SetStringValue(L"Publisher", (LPCWSTR) get_company_name().utf16()) ||
                ERROR_SUCCESS != key_icq.SetStringValue(L"InstallLocation", install_path) ||
                ERROR_SUCCESS != key_icq.SetStringValue(L"UninstallString", uninstall_command)
                )
            {
                return installer::error(errorcode::set_registry_value, "set registry value: Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\icq.desktop\\...");
            }

            return installer::error();
        }
Beispiel #2
0
        installer::error copy_self(const QString& _install_path)
        {
            wchar_t buffer[1025];
            if (!::GetModuleFileName(0, buffer, 1024) || !::CopyFile(buffer, (const wchar_t*)(_install_path + "/" + get_installer_exe_short()).utf16(), FALSE))
                return installer::error(errorcode::copy_installer, QString("copy installer: ") + get_installer_exe());

            return installer::error();
        }