就象在控制面板中打开"添加/删除程序"中出现的软件列表一样.
解决方案 »
- 为TCnAAScrollText增加透明属性
- 想找一个指导自己DELPHI网络编程 有报酬
- 求助,做过打包的兄弟,有请了!
- adoconnection连接sql server 时间问题,高手请进!!!!!!!!!!!!急!在线等待.......
- 用存储过程删除关联表,怎么删除!
- 字符串處理。
- Delphi 哪个grid可以行多选(比如按ctrl健对不连续的行多选)
- DataModule4.ClientDataSet1.Locate的问题求救!
- MIDAS中的奇怪问题!数据集不更新的问题,大家来看看,解决了可以再加分!
- 关于窗口的问题,请各位帮忙,谢谢!
- 菜鸟100分请教:如何在DBGRID中拖拽记录,重新排序????
- 鼠标在 标题栏(caption)上滑过,激发的消息是哪一个??怎么判断是在caption上?
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall]的内容就是
自己用RegEdit都能看到的
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;
这是用了第三方的组件