advanced installer保姆级做包教程


特别说明:本教程使用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一下,查看效果:
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

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

猜你喜欢

转载自blog.csdn.net/qq_41750806/article/details/122166802
今日推荐