请问用什么方法,可以像windows优化大师一样,把所有安装的软件都枚举出来。
解决方案 »
- 版里有空的人, 去整理了一下LY主页的资料吧
- schtasks在cmd窗口中输入正常,但使用delphi的shellexecute命令不行,怎么处理?
- 在线等!!动态创建数据库组件的问题
- Clientdataset的ApplyUpdates过程和UpdateRecord到底用哪个,有什么区别?
- 如何用程序控制ShellListView进入相应的目录???在线等
- 关于StringGrid的问题
- ActviexForm能否像Activex控件一样使用?
- 文件夹保护问题,高手请进!
- 能介绍几本delphi做数据库的书吗??
- 各位DELPHI区的朋友请进
- 如何实现rave让他不用预览,就直接打印呢?
- 怎么更改自己机器的ip地址?
Version : WinShop1.00
Author : JianYao
Time : 2003.6
}
unit Unit_soft;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, SUIForm, ComCtrls, SUIThemes,
shellapi,SUIButton, registry, ImgList,inifiles, StdCtrls,
SUIPageControl, SUITabControl;type
Tsoftwareinfo=record //软件信息记录类型类
SubKey:string; //主键
DisplayName:string; //软件名称
UninstallString:string; //软件卸载参数
end;
TSoftware=array of Tsoftwareinfo; //软件信息 Tform_soft = class(TForm)
form_inf1: TsuiForm;
btn_ext: TsuiButton;
btn_del: TsuiButton;
btn_uni: TsuiButton;
Imglst_lv: TImageList;
Label1: TLabel;
Bevel1: TBevel;
img_top: TImage;
Image1: TImage;
Btn_refresh: TsuiButton;
pc: TsuiPageControl;
ts1: TsuiTabSheet;
Lv_AllSoft: TListView;
ts2: TsuiTabSheet;
lv_CurSoft: TListView;
procedure btn_extClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure Btn_refreshClick(Sender: TObject);
procedure Lv_AllSoftSelectItem(Sender: TObject; Item: TListItem;
Selected: Boolean);
private
{ Private declarations }
procedure LoadSkin; {加载皮肤}
procedure LoadAllInfo; {获取所有软件信息}
procedure LoadInfo; {获取实际软件安装信息}
procedure LoadAllCurSoft; {获取当前用户所有软件信息}
procedure LoadCurSoft; {获取当前用户实际软件安装信息}
public
{ Public declarations }
end;var
form_soft: Tform_soft;
setinifile:Tinifile;
//------------------------------------------//
KeyLength:Integer; {所有用户实际软件信息长度}
AllSoftinf:TSoftware; {所有用户所有软件信息}
SoftInf:Tsoftware; {所有用户实际软件信息}
AllKeyLength:integer; {所有用户所有软件信息长度}
//------------------------------------------//
AllCurSoft:TSoftware; {当前用户所有软件信息}
CurSoft:TSoftware; {当前用户实际软件信息}
KeyLen:integer; {当前用户实际软件信息长度}
AllKeyLen:integer; {当前用户所有软件信息长度}
Soft,CurrentSoft:Tlistitem;
//------------------------------------------//
implementationuses Unit_main;{$R *.dfm}procedure Tform_soft.LoadAllInfo; {获取所有用户所有软件信息}
var
Reg: TRegistry;
Keys:TStringList;
i:Integer;
begin
KeyLength:=0;
Reg:=TRegistry.Create;
try //try 1
Keys:=TStringList.Create;
try //try 2
Reg.RootKey:=HKEY_LOCAL_MACHINE; // Section to look for within the registry
if Reg.OpenKey('\Software\Microsoft\Windows\CurrentVersion\uninstall',False) then //if 1
begin
Reg.GetkeyNames(Keys);
AllKeyLength:=Keys.Count;
setlength(AllSoftinf,AllKeyLength); //设置软件信息动态数组的长度
for I:=0 to AllKeyLength - 1 do
begin
if (reg.openkey('\software\microsoft\windows\currentversion\uninstall\'+Keys.Strings[i],FALSE)) then //if 2
begin
AllSoftinf[i].SubKey:='\software\microsoft\windows\currentversion\uninstall\'+Keys.Strings[i];
AllSoftinf[i].displayname:=reg.ReadString('DisplayName');
AllSoftinf[i].uninstallstring:=reg.ReadString('uninstallstring');
if (AllSoftinf[i].displayname<>'') then begin //if 3
inc(KeyLength); //获得软件信息记录长度
end; //end if 3
end //end if 2
else //else if 2
messagebox(application.handle,'打开注册表错误!请确定你有足够的权限!','错误',MB_ICONERROR);
end; //end for
end else //else if 1
messagebox(application.handle,'打开注册表错误!请确定你有足够的权限!','错误',MB_ICONERROR);
finally
Keys.Free;
end; //end try 2
finally
Reg.Free;
end; //end try 1
end;procedure TForm_soft.LoadInfo; {获取所有用户实际软件安装信息}
var
i,j:integer;
label GotoNext;
begin
i:=0;
setLength(SoftInf,KeyLength); //设置实际软件信息记录数组长度
for j:=0 to KeyLength - 1 do begin
if (i<=AllKeyLength-1) then begin //if 1
GotoNext:
if AllSoftinf[i].displayname='' then begin //if 2
inc(i);
goto GotoNext;
end //end if 2
else begin //else if 2
SoftInf[j].SubKey:=AllSoftinf[i].SubKey;
SoftInf[j].displayname:=AllSoftinf[i].displayname;
SoftInf[j].uninstallstring:=AllSoftinf[i].uninstallstring;
inc(i); //i++
end; //end if else
end; //end if
end; //End for j
end;
var
Reg: TRegistry;
Keys:TStringList;
i:Integer;
begin
KeyLen:=0;
Reg:=TRegistry.Create;
try //try 1
Keys:=TStringList.Create;
try //try 2
Reg.RootKey:=HKEY_Current_USER; // Section to look for within the registry
if Reg.OpenKey('\Software\Microsoft\Windows\CurrentVersion\uninstall',False) then //if 1
begin
Reg.GetkeyNames(Keys);
AllKeyLen:=Keys.Count;
setlength(AllCurSoft,AllKeyLen); //设置软件信息动态数组的长度
for I:=0 to AllKeyLen - 1 do
begin
if (reg.openkey('\software\microsoft\windows\currentversion\uninstall\'+Keys.Strings[i],FALSE)) then //if 2
begin
AllCurSoft[i].SubKey:='\software\microsoft\windows\currentversion\uninstall\'+Keys.Strings[i];
AllCurSoft[i].displayname:=reg.ReadString('DisplayName');
AllCurSoft[i].uninstallstring:=reg.ReadString('uninstallstring');
if (AllCurSoft[i].displayname<>'') then begin //if 3
inc(KeyLen); //获得软件信息记录长度
end; //end if 3
end //end if 2
else //else if 2
messagebox(application.handle,'打开注册表错误!请确定你有足够的权限!','错误',MB_ICONERROR);
end; //end for
end else //else if 1
messagebox(application.handle,'打开注册表错误!请确定你有足够的权限!','错误',MB_ICONERROR);
finally
Keys.Free;
end; //end try 2
finally
Reg.Free;
end; //end try 1
end;procedure TForm_soft.LoadCurSoft; {获取当前用户实际软件安装信息}
var
k,l:integer;
label Next;
begin
k:=0;
setLength(CurSoft,KeyLen); //设置实际软件信息记录数组长度
for l:=0 to KeyLen - 1 do begin
if (k<=AllKeyLen - 1) then begin //if 1
Next:
if AllCurSoft[k].displayname='' then begin //if 2
inc(k);
goto Next;
end //end if 2
else begin //else if 2
CurSoft[l].SubKey:=AllCurSoft[k].SubKey;
CurSoft[l].displayname:=AllCurSoft[k].displayname;
CurSoft[l].uninstallstring:=AllCurSoft[k].uninstallstring;
inc(k); //i++
end; //end else
end; //end if
end; //End for j
end;procedure Tform_soft.LoadSkin; //初始化软件界面
var
filename:string;
theme:integer;
begin
try
filename:=extractfilepath(paramstr(0))+'set.ini';
setinifile :=tinifile.Create(filename);
theme:=setinifile.ReadInteger('Winshop','theme',0);
finally
setinifile.Free;
end; case theme of
0 : begin
form_inf1.UIStyle := MacOS;
btn_uni.Height:=23;
btn_del.Height:=23;
Btn_refresh.Height:=23;
btn_ext.Height:=23;
Height:=440;
end; //end 0
1 : begin
form_inf1.UIStyle := WinXP;
btn_uni.Height:=23;
btn_del.Height:=23;
Btn_refresh.Height:=23;
btn_ext.Height:=23;
Height:=440;
end; //end 1
2 : begin
form_inf1.UIStyle := DeepBlue;
btn_uni.Height:=23;
btn_del.Height:=23;
Btn_refresh.Height:=23;
btn_ext.Height:=23;
Height:=440;
end; //end 2
3 : begin
form_inf1.UIStyle := Protein;
btn_uni.Height:=23;
btn_del.Height:=23;
Btn_refresh.Height:=23;
btn_ext.Height:=23;
Height:=440;
end; //end 3
4 : begin
form_inf1.UIStyle := BlueGlass;
btn_uni.Height:=27;
btn_del.Height:=27;
Btn_refresh.Height:=27;
btn_ext.Height:=27;
Height:=444;
end; //end 4
end; //end case
img_top.Picture.Bitmap.LoadFromResourceName(hInstance,'OtherBar'); //加载窗口顶部图片
end; //初始化软件界面procedure Tform_soft.btn_extClick(Sender: TObject);
begin
form_soft.Close;
end;procedure Tform_soft.FormCreate(Sender: TObject);
var
i,j:integer;
begin
pc.ActivePage:=ts1;
LoadSkin; {加载皮肤}LoadAllInfo; {获取所有用户所有软件信息}
LoadInfo; {获取所有用户实际软件安装信息}
LoadAllCurSoft; {获取当前用户所有软件信息}
LoadCurSoft; {获取当前用户实际软件安装信息}lv_AllSoft.Clear;
for i:=0 to KeyLength - 1 do begin {显示所有用户实际软件信息}
soft:=Lv_AllSoft.Items.Add;
soft.Caption:=SoftInf[i].displayname;
soft.SubItems.Add(SoftInf[i].uninstallstring);
end; //end forLv_CurSoft.Clear;
for j:=0 to KeyLen - 1 do begin {显示当前用户软件实际信息}
Currentsoft:=Lv_CurSoft.Items.Add;
Currentsoft.Caption:=CurSoft[j].displayname;
Currentsoft.SubItems.Add(CurSoft[j].uninstallstring); //end if
end; //end forend;procedure Tform_soft.FormDestroy(Sender: TObject);
begin
img_top.Free;
end;procedure Tform_soft.Btn_refreshClick(Sender: TObject);
var
i,j:integer;
begin
case pc.ActivePageIndex of
0:begin //当PageControl的焦点在所有软件信息上时
LoadAllInfo; {获取所有用户所有软件信息}
LoadInfo; {获取所有用户实际软件安装信息}
lv_AllSoft.Clear;
for i:=0 to KeyLength - 1 do begin {显示所有用户实际软件信息}
soft:=Lv_AllSoft.Items.Add;
soft.Caption:=SoftInf[i].displayname;
soft.SubItems.Add(SoftInf[i].uninstallstring);
end; //End For
end; //End 0 1:begin //当PageControl的焦点在用户软件信息上时
LoadAllCurSoft; {获取当前用户所有软件信息}
LoadCurSoft; {获取当前用户实际软件安装信息}
Lv_CurSoft.Clear;
for j:=0 to KeyLen - 1 do begin {显示当前用户软件实际信息}
Currentsoft:=Lv_CurSoft.Items.Add;
Currentsoft.Caption:=CurSoft[j].displayname;
Currentsoft.SubItems.Add(CurSoft[j].uninstallstring); //end if
end; //end for
end;//End 1
end; //End Case
end;{刷新软件信息列表}procedure Tform_soft.Lv_AllSoftSelectItem(Sender: TObject; Item: TListItem;
Selected: Boolean);
var
i,j:integer;
begin
case pc.ActivePageIndex of
0: begin //当PageControl的焦点在所有用户软件信息上时
btn_uni.Enabled:=True;
btn_del.Enabled:=True;
//for i:=0 to lv_AllSoft.Items.Count - 1 do begin
//if lv_AllSoft.Items.Item[i].Selected then begin //end else begin //end if & begin else if //end; //end else if
//end; //End for
end; //End 0 1: begin //当PageControl的焦点在当前用户软件信息上时
end; //End 1
end;//End case
end;end.
SUIButton, SUIPageControl, SUITabControl;
你这是用了第三方的组件吧?
我没有看明白这是什么?
SUIPack
www.2ccc.com上有下载