advanced installer保姆级做包教程

这篇博客详细介绍了如何使用AdvancedInstaller19.0创建Qt程序的安装包,包括添加项目信息、设置图标、添加文件、创建快捷方式等基础操作。还涉及到了安装包类型的修改、批处理文件调用、开机启动设置、安装包位数选择、环境限制和监测、安装前后逻辑处理、主题更换、在线升级策略以及软件试用期限制等高级功能。文章通过实例演示了软件试用期限制的实现,并给出了相关代码示例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


特别说明:本教程使用advanced installer 19.0版本,所打包的程序为Qt程序

基础操作

一、生成项目

在这里插入图片描述

二、添加产品基本信息以及图标(控制面板)

在这里插入图片描述

三、添加项目文件(.exe以及运行所需文件)

在这里插入图片描述
添加完文件后:
在这里插入图片描述

三、添加桌面快捷方式

在这里插入图片描述
选择应用文件中的.exe文件,点击OK
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

构建

点击build->选择存储路径->确定
在这里插入图片描述
在这里插入图片描述
此处已完成一个简单的安装包
在这里插入图片描述
在setupfiles文件夹中就是生成的安装包。
在这里插入图片描述

可选操作

一、修改安装包类型

.msi、.exe类型可自行修改
在这里插入图片描述

二、调用批处理文件

如项目文件夹内无该批处理文件,则需手动添加
在这里插入图片描述
在这里插入图片描述如项目文件夹内已有该批处理文件,直接进行此步
在这里插入图片描述

三、设置开机自动启动

首先,开机自动启动是通过写注册表的方法实现的,我们先找到开机启动的注册表位置,本机开机启动项如下:
在这里插入图片描述
正式操作如下
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

四、安装包位数

在这里插入图片描述

五、运行环境限制(系统+硬件+软件)

在这里插入图片描述

六、运行环境监测及指定安装文件

在这里插入图片描述
在这里插入图片描述
咱们目前是限制最小版本、以及未安装时进行安装,贴心的是软件已经给我们设置好了版本限制,但是并未设置好未安装时进行安装,需要我们自行设置,设置步骤如下
在这里插入图片描述
VC++注册表键值地址可查看我的另一篇博客
查看是否安装了VC++ 2015-2019 Redistributeable

七、安装完成自动启动程序

在这里插入图片描述

八、安装前卸载旧版本

在这里插入图片描述

UninstallPreviousVersions操作是通过 UpgradeCode来查找旧版本的,所以只要确保新旧版本的UpgradeCode一致(product Code千万不能一致)就可以在安装新版本的时候自动卸载旧版本了。
UpgradeCode:
在这里插入图片描述

九、更换主题等

用户可根据需要进行主题的切换、自绘对话框、安装过程(全屏显示)的幻灯片、以及语言选项,可玩性比较高,小伙伴们自行测试吧
在这里插入图片描述

十、在线升级

哈哈,没办法,目前还没用到这个功能,等到用到会补充~
借用别人的教程
该功能最好去看官方文档,这里简单介绍一下该功能:
在这里插入图片描述
主要思路就是:
1.将最新的exe路径和版本信息等以固定的格式放在网上
2.绿色包也要放在网上
3.调用安装后在软件根目录的updater.exe进行检查下载。
这一套都是该软件做好的,我们提供网上资源和资源信息就好了。补丁包会更加麻烦一些,需要做msi包,进行本版本和下一版本比较生成补丁文件~
原文链接:https://blog.csdn.net/qq_37887537/article/details/84325944

升级操作

作为公司类的产品,当然少不了加密授权的操作,软硬加密狗诸如此类,每次想从网上下载资源或者软件进行白嫖,但是人家都能蹦出个授权码、密码啥的,或者带有试用期,真是不给活路。好吧,咱们也不能让别人直接白嫖不是,罪(zhen)过(shuang)~

一、安装包的加密

在这里插入图片描述
然后安装过程中。。。。。。。。。。。。。。。
在这里插入图片描述

二、软件试用期限制

在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

在这里插入图片描述
生成的注册码如下:
在这里插入图片描述

生成的动态库:
在这里插入图片描述
接下来需要在咱们的程序里添加联动代码

// trial function signature
typedef UINT (__stdcall * TrialFcn)(LPCSTR, HWND);

// register function signature
typedef UINT (__stdcall * RegisterFcn)(LPCSTR, LPCWSTR);

int InitLicensingSupport(LPCSTR aKeyCode, HWND aHWnd)
{
  HMODULE hModule = ::LoadLibrary("suibian.dll");
  if(hModule == NULL)
    return -1; // Missing Trial DLL;

  TrialFcn readSettingsProc = reinterpret_cast<TrialFcn>(
    ::GetProcAddress(hModule, "ReadSettingsStr"));

  if(readSettingsProc == NULL)
    return -1; // Missing Trial DLL;

  // Return values:
  // "0" - the application is registered (a valid license key was found);
  // "2" - the application is in trial mode;
  // If the application trial period has expired and the user will NOT enter
  // a valid license key, the process will be killed by the function
  // instead of returning one of the codes above.
  int ret = readSettingsProc(aKeyCode, aHWnd);

  return ret;
}

int DisplayRegistrationDlg(LPCSTR aKeyCode, HWND aHWnd)
{
  HMODULE hModule = ::LoadLibrary("suibian.dll");
  if(hModule == NULL)
    return -1; // Missing Trial DLL;

  TrialFcn displayRegProc = reinterpret_cast<TrialFcn>(
    ::GetProcAddress(hModule, "DisplayRegistrationStr"));

  if(displayRegProc == NULL)
    return -1; // Missing Trial DLL;

  // Return values:
  // "0" - the application is registered (a valid license key was found/entered);
  // "2" - the application is in trial mode;
  int ret = displayRegProc(aKeyCode, aHWnd);

  ::FreeLibrary(hModule);

  return ret;
}

int RegisterLicense(LPCSTR aKeyCode, LPCWSTR aLicense)
{
  HMODULE hModule = ::LoadLibrary("suibian.dll");
  if(hModule == NULL)
    return -1; // Missing Trial DLL;

  RegisterFcn registerLicense = reinterpret_cast<RegisterFcn>(
    ::GetProcAddress(hModule, "RegisterStr"));

  if(registerLicense == NULL)
    return -1; // Missing Trial DLL;

  // Return values:
  // "0" - the license was successfully saved on local machine; notice that the license validation is not done when using the "RegisterStr" function
  // "different than 0" - the license couldn't be saved on local machine
  int ret = registerLicense(aKeyCode, aLicense);

  ::FreeLibrary(hModule);

  return ret;
}
        

在刚进程序的地方添加调用函数即可


#define kLibraryKey "52C55AA6D662A785EE887C42D403486B7401D62E32AF681B7E2E12BBEA5E9BC342013F48A2D2"

// Immediately after the main application is launched initialize licensing support
void OnInit(...)
{
  // Optionally, you can specify a parent window for the licensing messages
  HWND parentWnd = m_hWnd; // can be NULL

  int ret = InitLicensingSupport(kLibraryKey, parentWnd);

  // Trial DLL is missing exit to protect the application
  // (you might choose to handle this differently -  exit application nicely)
  if(ret == -1)
    exit(0);

  // You can save and use the return code (ret) to display the application registration state

  // Continue loading your application...
  // ...

}

// When the client wants to register your application, this is how you should handle it
LRESULT OnRegister(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL & /*bHandled*/)
{
  // Display the trial dialog.
  int ret = DisplayRegistrationDlg(kLibraryKey, m_hWnd);

  // You can save and use the return code (ret) to update the application registration state

  return 0;
}

........
      

加入联动代码后,记得生成最新的exe程序

三、最终效果

run一下,查看效果:
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
未完待续~有问题请留言,感谢!

Advanced Installer是一款功能强大的打工具,用于创建和打Windows安装程序。下面是一个简单的Advanced Installer教程: 第一步:准备工作 下载并安装Advanced Installer软件。安装完成后,打开软件界面。 第二步:创建新项目 点击“新建”按钮,选择“New Project”。在弹出的对话框中,选择项目的类型和名称,并点击“下一步”。 第三步:配置基本设置 在“设置”页面,可以配置软件的基本信息,如安装程序名称、版本号、目标文件夹等。点击“下一步”继续。 第四步:添加文件和文件夹 在“文件和文件夹”页面,可以添加要打的文件和文件夹。点击“添加文件”或“添加文件夹”按钮,选择要打的内容,并设置安装位置和其他属性。 第五步:配置选项 在“选项”页面,可以配置安装程序的选项,如启动菜单目录、快捷方式、注册表项等。根据需要进行设置,并点击“下一步”。 第六步:配置安装界面 在“安装界面”页面,可以自定义安装界面的外观和布局。可以添加自定义的图片、文本和按钮等元素。完成后,点击“下一步”。 第七步:配置操作 在“操作”页面,可以设置安装过程中需要执行的操作,如创建快捷方式、注册COM组件等。根据需要进行设置,并点击“下一步”。 第八步:构建安装程序 在“构建”页面,可以选择要构建的安装程序类型,如MSI、EXE等。可以设置安装的属性,如输出目录、压缩方式等。完成设置后,点击“构建”按钮,等待构建完成。 第九步:测试和发布 构建完成后,可以进行测试安装程序的功能和界面。如果一切正常,可以选择发布安装程序,生成可执行文件或安装。 这就是一个简单的Advanced Installer教程。通过这些步骤,您可以使用Advanced Installer创建并打定制的Windows安装程序。
评论 19
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值