• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Delphi中启动项管理已安装程序卸载简单组件

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

主要代码如下:

 

1 {*******************************************************}
2  { }
3  { UWSStartupItemPanel }
4 { Mail:[email protected] }
5 { 版权所有 (C) 2009 Unruly Wolf Soft }
6 { }
7 { 版本:0.1.0.8 }
8 { }
9 { 创建日期:2009年11月5日 }
10 { }
11 { 功能: }
12 { 1、启动项管理(完成度99%) }
13 { 2、软件卸载(完成度80%) }
14 {*******************************************************}
15
16 {********************************************************}
17 { 版本升级记录: }
18 { 2009年10月20日:构思控件 }
19 { 2009年10月22日:开始设计控件 }
20 { 2009年10月23日:改进数项功能设计 修复Bug }
21 { 2009年10月24日:0.1.0.0版完成,实现启动项基本管理功能:}
22 { 1、启动项查看 }
23 { 2、删除 }
24 { 3、禁止使用 }
25 { 4、编辑 }
26 { 5、新增启动项 }
27 { 2009年10月27日:完成TUWSUnInstallPanel 组件开发 }
28 { 2009年11月1日:为TUWSStartPanel增加两个事件: }
29 { BeforReload AfterReload }
30 { 2009年11月2日:TUWSUninstallPanel.DelReg完成 }
31 {********************************************************}
32
33 unit UWSStartItemPanel;
34
35 interface
36
37 uses
38 SysUtils, Classes, Controls, ExtCtrls,Graphics,StdCtrls,Forms,
39 StartupItemEditor,ShellAPI,Messages,Registry,Windows,Dialogs,
40 StrUtils,U_ViewCMDInfos;
41
42 const
43 KeyRun= '\SOFTWARE\Microsoft\Windows\CurrentVersion\Run';
44 KUninstallRegPath = 'Software\Microsoft\Windows\CurrentVersion\Uninstall';
45 KUninstallString = 'UninstallString';
46 KDisplayName = 'DisplayName';
47 KDisplayVersion='DisplayVersion';
48 KInstallDate='InstallDate';
49 KInstallLocation='InstallLocation';
50 KModifyPath='ModifyPath';
51 KPublisher='Publisher';
52 KURLInfoAbout='URLInfoAbout';
53 KDisplayIcon='DisplayIcon';
54 KQuietUninstallString='QuietUninstallString';
55 KISAP='Inno Setup: App Path';
56
57 {TUWSStartupItem}
58
59 type
60 TUWSStartupItem = class(TPanel)
61 private
62 { Private declarations }
63 BtnDel:TButton;
64 BtnForbidden:TButton;
65 BtnEdit:TButton ;
66 BtnViewCMDInfo:TButton ;
67 LabelCaption:TLabel ;
68 ImageIcon:TImage;
69 RealCommandLine:string;
70 FStartItemCaption:String;
71 FCmdLine:String;
72 FStartItemPostion:string;
73 FItemIndex:Integer ;
74 Forbiddened:Boolean ;
75 procedure UpateItem;
76 procedure BuildItemPropeties;
77 procedure CMMouseEnter(var Message: TMessage); message CM_MOUSEENTER;
78 procedure CMMouseLeave(var Message: TMessage); message CM_MOUSELEAVE;
79 protected
80 { Protected declarations }
81 procedure DsItem;
82 public
83 { Public declarations }
84 constructor Create(AOwner: TComponent); override;
85 destructor Destroy; override;
86 property CmdLine:string read FCmdLine write FCmdLine;
87 property StartItemPostion :string read FStartItemPostion write FStartItemPostion;
88 procedure DelStartupItem;
89 procedure ForbiddenStartupItem;
90 procedure EditStartupItem;
91 procedure ViewCMDLineInfo;
92 procedure SetupStartupItem(ItemCaption,ItemCmd,ItemPostion:string);
93 property StartItemCapTion: string read FStartItemCaption write FStartItemCaption;
94 property ItemIndex:integer read FItemIndex write FItemIndex;
95 published
96 { Published declarations }
97 end;
98
99 {TUWSUnInstallItem}
100
101 TUWSUnInstallItem = class(TPanel)
102 private
103 { Private declarations }
104 BtnStandardUnInstall:TButton ;
105 BtnDelRegString:TButton ;
106 BtnForceUnInstall:TButton ;
107 BtnModify:TButton ;
108 BtnQuitUnInstall:TButton ;
109 IconImage:TImage ;
110 FInstallPath:String;
111 FUnInstallCmd:String;
112 FDisplayName:String;
113 FInstallLocation:String;
114 FQuietUninstallCmd:String;
115 FModifyPath:string;
116 FRegKeyName:string;
117 FIsWindowsUpData:Boolean ;
118 procedure SetupItemPropeties;
119 procedure CMMouseEnter(var Message: TMessage); message CM_MOUSEENTER;
120 procedure CMMouseLeave(var Message: TMessage); message CM_MOUSELEAVE;
121 protected
122 { Protected declarations }
123 public
124 { Public declarations }
125 constructor Create(AOwner: TComponent); override;
126 destructor Destroy; override;
127 property InstallPath : string read FInstallPath write FInstallPath;
128 property UnInstallCmd : string read FUnInstallCmd write FUnInstallCmd;
129 property DisplayName : string read FDisplayName write FDisplayName;
130 property IsWindowsUpdata : Boolean read FIsWindowsUpdata write FIsWindowsUpdata;
131 property RegKeyName : string read FRegKeyName write FRegKeyName;
132 property InstallLocation : string read FInstallLocation write FInstallLocation;
133 property QuietUninstallCmd : string read FQuietUninstallCmd write FQuietUninstallCmd;
134 property ModifyPath : string read FModifyPath write FModifyPath;
135 published
136 { Published declarations }
137 procedure DoStandardUnInstall;
138 procedure DoDelUnInstallRegInfo;
139 procedure DoUnInstallAndClearn;
140 procedure DoModify;
141 procedure DoQuietUninstall;
142 end;
143
144 {TUWSStartItemPanel}
145
146 TUWSStartItemPanel = class(TScrollBox)
147 private
148 { Private declarations }
149 ItemList:TStringList;
150 WatchTime:TTimer;
151 ItemChangedTime:TTimer;
152 FMyWatchTime:Cardinal;
153 FAllowautorefresh:Boolean ;
154 FBeforeReload:TNotifyEvent;
155 FAfterReload:TNotifyEvent;
156 function GetItemCount:Integer ;
157 function FindAndBuildStartup(const ADirectoryName: string;SubDirs: TStrings): Boolean;
158 function SearchStartup(const ADirectoryName: string): Boolean;
159 procedure WatchItemOnWatch(Sender:TObject);
160 procedure ItemChangedTimer(Sender:TObject);
161 procedure DelItem(Sender:TObject);
162 procedure EditItem(Sender:TObject);
163 procedure BtnViewInfoClick(Sender:TObject);
164 procedure ForbiddenItem(Sender:TObject);
165 procedure SetWatchTime(aValue:Cardinal);
166 procedure SetAllowautorefresh(aValue:Boolean);
167 protected
168 { Protected declarations }
169 public
170 { Public declarations }
171 constructor Create(AOwner: TComponent); override;
172 destructor Destroy; override;
173 procedure LoadAllStartup;
174 procedure DestroyAllStartupItem;
175 procedure AddNewItem;
176 procedure ReLoadStartItems;
177 procedure MakeForbiddenItemDir;
178 property ItemCount : Integer read GetItemCount;
179 published
180 { Published declarations }
181 property MyWatchTime:Cardinal read FMyWatchTime write SetWatchTime;
182 property Allowautorefresh:Boolean read FAllowautorefresh write SetAllowautorefresh;
183 property BeforeReload : TNotifyEvent read FBeforeReload write FBeforeReload;
184 property AfterReload : TNotifyEvent read FAfterReload write FAfterReload;
185 end;
186
187 {TUWSUnInstallPanel}
188
189 TUWSUnInstallPanel = class(TScrollBox)
190 private
191 { Private declarations }
192 ItemList:TStringList;
193 FShowWinUPs:Boolean ;
194 FShowItemHint:Boolean ;
195 procedure StandardUnInstall(Sender:TObject);
196 procedure UnInstallAndClearn(Sender:TObject);
197 procedure DelReg(Sender:TObject);
198 procedure ModifyInstall(Sender:TObject);
199 procedure StaticUnInstall(Sender:TObject);
200 protected
201 { Protected declarations }
202 public
203 { Public declarations }
204 constructor Create(AOwner: TComponent); override;
205 destructor Destroy; override;
206 procedure LoadAllUnInstallInfos(ShowWinUP:Boolean);
207 procedure ReLoadUnInstallInfos;
208 procedure DestroyUnInstallInfos;
209 procedure SetWinUPVisable;
210 procedure SetShowItemHint;
211 published
212 { Published declarations }
213 property ShowWinUPs : Boolean read FShowWinUPs write FShowWinUPs;
214 property ShowItemHint : Boolean read FShowItemHint write FShowItemHint;
215 end;
216
217 procedure Register;
218
219 implementation
220
221 procedure Register;
222 begin
223 RegisterComponents('uws Used', [TUWSStartItemPanel,TUWSUnInstallPanel]);
224 end;
225
226 {UWSStartupItem}
227
228 procedure TUWSStartupItem.DelStartupItem ;
229 var
230 Reg:TRegistry;
231 RunItemName,RunItemDir,RunItemFile:string;
232 begin
233 begin
234 RunItemName:=FStartItemCaption;
235 RunItemDir:=FStartItemPostion;
236 RunItemFile:=FCmdLine;
237 if DirectoryExists(RunItemDir) then
238 begin
239 if not DeleteFile(PChar(RunItemFile)) then
240 Application.MessageBox(pchar(Format('删除%s失败!!',[RunItemName])), PChar(Application.Title),
241 MB_OK + MB_ICONSTOP + MB_TOPMOST);
242 end
243 else
244 begin
245

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Matlab: 主函数和子函数间接传递变量 - DocNan发布时间:2022-07-18
下一篇:
matlab 各类函数区别定义发布时间:2022-07-18
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap