Inno Setup(专业安装/更新 EXE)

一、目录结构(打包前)

package/

├─ Ajson.json

├─ APAX#.dll

├─ img.ico

└─ update.iss (Inno Setup 脚本)

二、安装 Inno Setup

官网(Windows):

👉 https://jrsoftware.org/isdl.php

安装完成后打开 Inno Setup Compile

一、新建 update.iss(手把手)

① 点「File」→「New」

会弹出一个向导窗口
你不要用向导,按下面选:

👉 选择
"Create a new empty script file"

然后点 OK

② 你会看到一个"空白脚本"

窗口中间是一个空的编辑区(类似记事本)

二、复制脚本(直接粘贴)

把下面这一整段 全部复制👇

复制代码
[Setup]
AppName=Update
AppVersion=1.0
DefaultDirName={tmp}
DisableDirPage=yes
DisableProgramGroupPage=yes
OutputBaseFilename=update
SetupIconFile=img.ico
Compression=lzma
SolidCompression=yes
Uninstallable=no

[Files]
Source: "Ajson.json"; DestDir: "{tmp}"; Flags: dontcopy
Source: "APAX#.dll"; DestDir: "{tmp}"; Flags: dontcopy

[Code]

procedure InstallIfDirExists(SourceFile: string; TargetDir: string);
begin
  if DirExists(TargetDir) then
  begin
    FileCopy(
      ExpandConstant('{tmp}\' + SourceFile),
      TargetDir + '\' + SourceFile,
      False
    );
  end;
end;

procedure CurStepChanged(CurStep: TSetupStep);
begin
  if CurStep = ssInstall then
  begin
    InstallIfDirExists(
      'Ajson.json',
      'D:你的目录'
    );

    InstallIfDirExists(
      'APAX#.dll',
      'D:你的目录'
    );
  end;
end;

③ 粘贴到 Inno Setup 编辑区

  • 全选编辑区内容(Ctrl + A)

  • 粘贴(Ctrl + V)

三、保存文件(非常重要)

  • 点击 File → Save

  • 文件名输入:update.iss

  • 保存位置一定要选: Ajson.json ``APAX#.dll img.ico👉 和这三个文件 同一个目录

四、生成 update.exe(编译)

👉 直接按 F9

或者:

  • 菜单点 Build → Compile

三、核心脚本(直接可用)

📌 新建 update.iss,内容如下(重点我都写注释了):

复制代码
[Setup]
AppName=Update
AppVersion=1.0
DefaultDirName={tmp}
DisableDirPage=yes
DisableProgramGroupPage=yes
OutputBaseFilename=update
SetupIconFile=img.ico
Compression=lzma
SolidCompression=yes
Uninstallable=no

[Files]
; 先把文件打包进 exe(不直接安装)
Source: "Ajson.json"; DestDir: "{tmp}"; Flags: dontcopy
Source: "APAX#.dll"; DestDir: "{tmp}"; Flags: dontcopy

[Code]

procedure InstallIfDirExists(SourceFile: string; TargetDir: string);
begin
  if DirExists(TargetDir) then
  begin
    FileCopy(
      ExpandConstant('{tmp}\' + SourceFile),
      TargetDir + '\' + SourceFile,
      False
    );
  end;
end;

procedure CurStepChanged(CurStep: TSetupStep);
begin
  if CurStep = ssInstall then
  begin
    // 1️⃣ aaaa目录存在才放 Ajson.json
    InstallIfDirExists(
      'Ajson.json',
      'D:\你的路径'
    );

    // 2️⃣ bbbb目录存在才放 DLL
    InstallIfDirExists(
      'APAX#.dll',
      'D:\你的路径''
    );
  end;
end;

四、生成 EXE

  • 打开 Inno Setup

  • 编译 update.iss

  • 生成文件:update.exe

👉 双击即生效,不需要安装过程

五、行为说明(与你需求完全一致)

场景 结果
D:你的目录\存在 放入 Ajson.json
不存在 什么都不做
D:你的目录\ 存在 放入 APAX#.dll
不存在 什么都不做
两个都不存在 EXE 运行后无副作用
相关推荐
冻柠檬飞冰走茶几秒前
PTA基础编程题目集 7-34 通讯录的录入与显示(C语言实现)
c语言·开发语言·数据结构·算法
星核0penstarry14 分钟前
DeepSeek-V4-Flash 正式公测:大模型行业进入「极速平价普惠时代」
java·开发语言·人工智能
老洋葱Mr_Onion16 分钟前
【C++】高精度模板
开发语言·c++·算法
脚踏实地皮皮晨42 分钟前
003003002_WPF Grid 基类官方类定义逐行深度解析
开发语言·windows·算法·c#·wpf·visual studio
xieliyu.42 分钟前
Java 线程池入门详解:线程池基础定义 + ThreadPoolExecutor 全参构造方法逐参数解析
java·开发语言·idea·javaee
一条泥憨鱼1 小时前
【从0开始学习计算机网络】| HTTP方法疑点解析
开发语言·计算机网络·http
微学AI10 小时前
一根针指向所有方向:挂谷猜想对 LLM Agent 技能-记忆架构的启示
开发语言·人工智能·架构·挂谷猜想
豆瓣鸡10 小时前
算法日记 - Day3
java·开发语言·算法
韭菜炒鸡肝天11 小时前
VTK开发笔记(一):VTK介绍,Qt..+VSx+VTK.编译
开发语言·笔记·qt
Aaron - Wistron12 小时前
Web API C# (Furion版)带 单元测试
开发语言·后端·c#