INNO SETUP卸载程序中加入自定义窗体
[Setup]
AppName=My Program
AppVerName=My Program v.1.2
DefaultDirName={pf}/My Program
[Files]
Source: Files/*; DestDir: {app}
[Code]
const
bidDelAll = 1;
bidSkipAll = 2;
var
Form: TSetupForm;
CheckListBox: TNewCheckListBox;
AllButton, UnAllButton: TButton;
CancelButton, DelButton: TButton;
StaticText: TNewStaticText;
MsgForm: TSetupForm;
MsgAllButton, MsgSkipAllButton: TButton;
MsgCancelButton, MsgDelButton: TButton;
DelAllReadOnly: Boolean;
SkipAllReadOnly: Boolean;
CheckDirs, CheckFiles: Boolean;
function Size64(Hi, Lo: integer): Extended;
var
i: integer;
begin
Result:= Lo;
if Lo < 0 then
Result:= Result + 2147483647 + 2147483647 + 2;
i:= Hi;
while i > 0 do
begin
Result:= Result + 2147483647 + 2147483647 + 2;
i:= i - 1;
end;
end;
procedure FillListBox(const fromDir, fileMask: string; Level: Byte);
var
FSR, DSR: TFindRec;
FindResult: Boolean;
APath: string;
i: integer;
begin
APath := AddBackslash(fromDir);
FindResult := FindFirst(APath + fileMask, FSR);
try
while FindResult and CheckFiles do
begin
if FSR.Attributes and FILE_ATTRIBUTE_DIRECTORY = 0 then
begin
{files} i:= CheckListBox.AddCheckBox(FSR.Name,
FloatToStr(Size64(FSR.SizeHigh, FSR.SizeLow)) + ' byte',
Level, True, True, False, True, TStringList.Create);
TStrings(CheckListBox.ItemObject[i]).Text:= APath + FSR.Name;
end;
FindResult := FindNext(FSR);
end;
FindResult := FindFirst(APath + '*.*', DSR);
while FindResult and CheckDirs do
begin
CheckFiles:= True;
if ((DSR.Attributes and FILE_ATTRIBUTE_DIRECTORY) = FILE_ATTRIBUTE_DIRECTORY) and
not ((DSR.Name = '.') or (DSR.Name = '..')) then
begin
{dir} i:= CheckListBox.AddCheckBox(DSR.Name,'DIR', Level,
True, True, False, True, TStringList.Create);
TStrings(CheckListBox.ItemObject[i]).Text:= APath + DSR.Name;
{Recursion} FillListBox(APath + DSR.Name, fileMask, Level+1);
end;
FindResult := FindNext(DSR);
end;
finally
FindClose(FSR);
FindClose(DSR);
end;
end;
procedure ButtonOnClick(Sender: TObject);
begin
if TButton(Sender).Tag = 0 then
CheckListBox.CheckItem(0, coCheckWithChildren)
else
CheckListBox.CheckItem(0, coUnCheck);
end;
procedure MsgButtonOnClick(Sender: TObject);
begin
Case TButton(Sender).Tag of
bidDelAll : DelAllReadOnly:= True;
bidSkipAll: SkipAllReadOnly:= True;
end;
MsgForm.Close;
end;
function DelMsgBox(FileName: string): Boolean;
var
MsgLabel: TLabel;
begin
MsgForm:= CreateCustomForm;
MsgForm.ClientWidth := ScaleX(400);
MsgForm.ClientHeight := ScaleY(120);
MsgForm.Caption := 'Files to delete';
MsgForm.Center;
MsgLabel := TLabel.Create(MsgForm);
MsgLabel.Left := ScaleX(20);
MsgLabel.Top := ScaleY(20);
MsgLabel.Caption:= FileName + ' is protected file or directory!' + #10#10#13 + 'Do you want to delete the file with READONLY attribute?';
MsgLabel.Parent := MsgForm;
MsgAllButton := TButton.Create(MsgForm);
MsgAllButton.Parent := MsgForm;
MsgAllButton.Width := ScaleX(75);
MsgAllButton.Height := ScaleY(23);
MsgAllButton.Left := ScaleX(20);
MsgAllButton.Top := MsgForm.ClientHeight - ScaleY(23 + 10);
MsgAllButton.Caption := 'Delete All';
MsgAllButton.Tag:= bidDelAll;
MsgAllButton.OnClick := @MsgButtonOnClick;
MsgSkipAllButton := TButton.Create(MsgForm);
MsgSkipAllButton.Parent := MsgForm;
MsgSkipAllButton.Width := ScaleX(75);
MsgSkipAllButton.Height := ScaleY(23);
MsgSkipAllButton.Left := MsgAllButton.Left + MsgAllButton.Width + ScaleX(10);
MsgSkipAllButton.Top := MsgForm.ClientHeight - ScaleY(23 + 10);
MsgSkipAllButton.Caption := 'Skip All';
MsgSkipAllButton.Tag:= bidSkipAll;
MsgSkipAllButton.OnClick := @MsgButtonOnClick;
MsgCancelButton := TButton.Create(MsgForm);
MsgCancelButton.Parent := MsgForm;
MsgCancelButton.Width := ScaleX(75);
MsgCancelButton.Height := ScaleY(23);
MsgCancelButton.Left := MsgForm.ClientWidth - MsgCancelButton.Width - ScaleX(20);
MsgCancelButton.Top := MsgForm.ClientHeight - ScaleY(23 + 10);
MsgCancelButton.Caption := 'Skip';
MsgCancelButton.ModalResult := mrCancel;
MsgDelButton := TButton.Create(MsgForm);
MsgDelButton.Parent := MsgForm;
MsgDelButton.Width := ScaleX(75);
MsgDelButton.Height := ScaleY(23);
MsgDelButton.Left := MsgCancelButton.Left - MsgDelButton.Width - ScaleX(10);
MsgDelButton.Top := MsgForm.ClientHeight - ScaleY(23 + 10);
MsgDelButton.Caption := 'Delete';
MsgDelButton.ModalResult := mrOk;
MsgForm.ActiveControl:= MsgCancelButton;
if MsgForm.ShowModal() = mrOk then
Result:= True
else
Result:= False;
end;
procedure DeleteFiles();
var
SR: TFindRec;
i: integer;
str: string;
ResultCode: Integer;
begin
DelAllReadOnly:= False;
SkipAllReadOnly:= False;
for i:= CheckListBox.Items.Count - 1 downto 0 do
begin
if CheckListBox.State[i] = cbChecked then
begin
str:= Trim(TStrings(CheckListBox.ItemObject[i]).Text);
FindFirst(str, SR);
if ((SR.Attributes and FILE_ATTRIBUTE_READONLY) = FILE_ATTRIBUTE_READONLY) then
if Not (DelAllReadOnly or SkipAllReadOnly) then
if DelMsgBox(SR.Name) then
Exec('attrib', ' -h -s -r ' + '"' + str + '"',
'', SW_HIDE, ewWaitUntilTerminated, ResultCode);
if DelAllReadOnly then
Exec('attrib', ' -h -s -r ' + '"' + str + '"',
'', SW_HIDE, ewWaitUntilTerminated, ResultCode);
FindClose(SR);
DeleteFile(str);
RemoveDir(str);
end;
end;
end;
procedure BrowseRemainedFiles();
begin
Form:= CreateCustomForm;
Form.ClientWidth := ScaleX(400);
Form.ClientHeight := ScaleY(400);
Form.Caption := 'Files to delete';
Form.Center;
StaticText := TNewStaticText.Create(Form);
StaticText.Left:= ScaleX(20);
StaticText.Top := ScaleY(8);
StaticText.Caption := 'Some elements could not be removed.' + #10#13 +
'These can be removed manually.' + #10#13#13 +
'Choose which are necessary to delete' + #10#13 +
'or press Cancel button.';
StaticText.Font.Color:= clBlue;
StaticText.Font.Style:= [fsBold];
StaticText.AutoSize := True;
StaticText.Parent := Form;
CheckListBox := TNewCheckListBox.Create(Form);
CheckListBox.Left:= ScaleX(20);
CheckListBox.Top:= ScaleY(20);
CheckListBox.Width:= Form.ClientWidth - ScaleX(20*2);
CheckListBox.Height:= Form.ClientHeight - ScaleY(23*2 + 20);
// CheckListBox.Offset:= 0;
CheckListBox.Parent:= Form;
AllButton := TButton.Create(Form);
AllButton.Parent := Form;
AllButton.Width := ScaleX(75);
AllButton.Height := ScaleY(23);
AllButton.Left := ScaleX(20);
AllButton.Top := Form.ClientHeight - ScaleY(23 + 10);
AllButton.Caption := 'Select All';
AllButton.Tag:= 0;
AllButton.OnClick := @ButtonOnClick;
UnAllButton := TButton.Create(Form);
UnAllButton.Parent := Form;
UnAllButton.Width := ScaleX(75);
UnAllButton.Height := ScaleY(23);
UnAllButton.Left := AllButton.Left + AllButton.Width + ScaleX(10);
UnAllButton.Top := Form.ClientHeight - ScaleY(23 + 10);
UnAllButton.Caption := 'Clear All';
UnAllButton.Tag:= 1;
UnAllButton.OnClick := @ButtonOnClick;
CancelButton := TButton.Create(Form);
CancelButton.Parent := Form;
CancelButton.Width := ScaleX(75);
CancelButton.Height := ScaleY(23);
CancelButton.Left := Form.ClientWidth - CancelButton.Width - ScaleX(20);
CancelButton.Top := Form.ClientHeight - ScaleY(23 + 10);
CancelButton.Caption := 'Cancel';
CancelButton.ModalResult := mrCancel;
CancelButton.Cancel := True;
DelButton := TButton.Create(Form);
DelButton.Parent := Form;
DelButton.Width := ScaleX(75);
DelButton.Height := ScaleY(23);
DelButton.Left := CancelButton.Left - DelButton.Width - ScaleX(10);
DelButton.Top := Form.ClientHeight - ScaleY(23 + 10);
DelButton.Caption := 'Delete';
DelButton.ModalResult := mrOk;
Form.ActiveControl:= CancelButton;
CheckListBox.AddCheckBox(ExpandConstant('{app}'), '', 0, True, True, False, True, TStringList.Create);
TStrings(CheckListBox.ItemObject[0]).Text:= ExpandConstant('{app}');
CheckDirs:= True;
FillListBox(ExpandConstant('{app}'), '*', 1);
CheckDirs:= False;
FillListBox(ExpandConstant('{app}'), '*', 1);
if Form.ShowModal() = mrOk then DeleteFiles();
end;
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
begin
if DirExists(ExpandConstant('{app}')) and (CurUninstallStep = usPostUninstall) then
BrowseRemainedFiles();
end;
INNO SETUP卸载程序中加入自定义窗体的更多相关文章
- Inno setup 卸载时删除程序文件夹(文件)
Inno setup 卸载时删除程序文件夹(文件) //删除所有配置文件以达到干净卸载的目的 procedure CurUninstallStepChanged(CurUninstallStep: T ...
- Inno Setup技巧[界面]添加和自定义左下角标签
原文 http://blog.sina.com.cn/s/blog_5e3cc2f30100cc49.html 本文介绍添加和自定义“左下角标签”的方法. 界面预览: Setup技巧[界面]添加和自定 ...
- C程序中引用自定义的C函数模块
原文:C程序中引用自定义的C函数模块 我们知道,刚开始接触C语言编程,一般都是在一个.c或者.cpp(以下只说.c)的文件中编写代码,其中一定会有一个入口函数, 也就是main()函数,你可以将程序代 ...
- 微信小程序中的自定义组件
微信小程序中的组件 前言 之前做小程序开发的时候,对于开发来说比较头疼的莫过于自定义组件了,当时官方对这方面的文档也只是寥寥几句,一笔带过而已,所以写起来真的是非常非常痛苦!! 好在微信小程序的库从 ...
- 使用inno setup打包程序完整脚本(.net框架检测,重复安装检测)
; 脚本由 Inno Setup 脚本向导 生成!; 有关创建 Inno Setup 脚本文件的详细资料请查阅帮助文档! #define MyAppName "小小鸟软件"#def ...
- Inno Setup安装程序单例运行
1.源起: KV项目下载底层升级包,老是报出升级文件占用问题,反复分析,不得其所. 今天突然发现同时启动多个升级程序实例,分析认为安装包同时被调用多次,引发实例访问文件冲突,导致此问题. 安装程序由I ...
- Inno Setup卸载时注销bho
Inno setup是一个制作安装包的免费工具,比如你用Qt开发完成一款软件,拿Inno setup打个安装包甩给客户安装就好了. 但是bho插件在注册后,万一用户卸载软件时,bho插件还是躺在管理加 ...
- 微信小程序中的自定义组件(components)
其实小程序开发很像vue和react的结合,数据绑定和setData 重新渲染页面的数据,最近发现连写组件都是很像,也是醉了,自我认为哈, 因为小程序可以将页面内的功能模块抽象成自定义组件,以便在 ...
- 在C#一个程序中,将一个窗体中的数据传送到另一个窗体
使用多个窗体搭建的程序,需要用到窗体间的数据传递,常用两种方法: 方法一 1,进入子窗体的Designer.cs,将子窗体中的私有控件控件定义为public 2.在主窗口程序Form1.cs中将子窗口 ...
随机推荐
- 站长VS微商 你选择哪个?
近期,站长圈里盛行起了一阵面膜风.我刷空间和微信朋友圈的时候,常常看到一些朋友在卖面膜,不光女童鞋在卖,男屌丝站长也在卖. 不光普通人在卖.行业圈的自媒体明星大佬也在卖. 我们暂且称卖面膜的童鞋为微商 ...
- dirname
dirname 命令来删除文件路径中最后一个/以及一些背后.当文件通常能够得到一个文件夹. 实例: dean@dean-Latitude-3330:~$ dirname /usr/bin/ /usr ...
- 并发队列ConcurrentLinkedQueue和阻塞队列LinkedBlockingQueue用法(转)
在Java多线程应用中,队列的使用率很高,多数生产消费模型的首选数据结构就是队列(先进先出).Java提供的线程安全的Queue可以分为阻塞队列和非阻塞队列,其中阻塞队列的典型例子是BlockingQ ...
- NSIS:禁止选择安装路径和编辑安装目录
原文 NSIS:禁止选择安装路径和编辑安装目录 如果你想在安装包中禁止用户选择安装路径和编辑安装目录,有两种方式. 第一种:注释或删除安装目录选择页面 1 ;!insertmacro MUI_PA ...
- testbench中将外部数据引入输出的方法(转载)
在进行HDL的仿真测试时,除了用较为直观的波形仿真图像以外,通过编写测试文件testbench进行仿真并将仿真结果保存在对应的文件,显得尤为重要.文件的操作主要用到读和写两种操作. 1. 读操作 读操 ...
- oracle中execute immediate的使用(select/insert/update/delete)(转)
execute immediate的语法如下: execute immediate 'sql'; execute immediate 'sql_select' into var_1, var_2; e ...
- acdream 1431 Sum vs Product
Sum vs Product Time Limit: 4000/2000MS (Java/Others)Memory Limit: 128000/64000KB (Java/Others) Submi ...
- 2014辛星完全解读html第五节
员,那么肯定会知道什么叫表单,这里我们就介绍一下前台怎样使用表单.表单的使用也是我们编写网页的必须经历的一关.并且,表单也往往是我们站点的漏洞和弱点出现的地方. *************表单**** ...
- CSS浏览器兼容性问题集()两
11.非常适合 高度适合于被改变时所述内目标高度的外层的高度不能自己主动调节,尤其是排队对象时margin 要么paddign 时. 例: #box {background-color:#e ...
- SEO要领:8文章主持技巧(两)
续篇:搜索引擎优化要领:8条辅助技巧(一) 四.检查你的robots.txt文件 与谷歌的蜘蛛通信的经常用法是使用robots.txt文件. 这是一个文本文件.同意你告诉搜索引擎,你的站点的网页上抓取 ...