Ejemplo n.º 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();
        }
Ejemplo n.º 2
0
        installer::error copy_files_from_updates()
        {
            wchar_t this_module_name[1024];
            if (!::GetModuleFileName(0, this_module_name, 1024))
                return installer::error(errorcode::get_module_name, QString("get this module name"));

            QFileInfo module_info(QString::fromUtf16((const ushort*) this_module_name));

            QDir update_dir = module_info.absoluteDir();

            update_dir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks);
            QFileInfoList files_list = update_dir.entryInfoList();

            for (int i = 0; i < files_list.size(); ++i)
            {
                QFileInfo file_info = files_list.at(i);

                QString file_path = file_info.absoluteFilePath();

                if (file_path != module_info.absoluteFilePath())
                {
                    file_path = QDir::toNativeSeparators(file_path);

                    QString new_file_name = QDir::toNativeSeparators(get_install_folder() + "/" + file_info.fileName());

                    for (int i = 0; i < 10; ++i)
                    {
                        if (::MoveFileEx((const wchar_t*) file_path.utf16(), (const wchar_t*) new_file_name.utf16(), MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING))
                            break;

                        ::Sleep(500);
                    }
                }
            }

            return installer::error();
        }
Ejemplo n.º 3
0
 installer::error copy_files()
 {
     return copy_files_to_folder(get_install_folder());
 }
Ejemplo n.º 4
0
 installer::error copy_self_from_updates()
 {
     return copy_self(get_install_folder());
 }