mainunit.pas
上传用户:psxgmh
上传日期:2013-04-08
资源大小:15112k
文件大小:3k
- unit mainunit;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, StdCtrls, Buttons, ExtCtrls,Registry;
- type
- TForm1 = class(TForm)
- GroupBox1: TGroupBox;
- Label1: TLabel;
- Edit1: TEdit;
- Label2: TLabel;
- Edit2: TEdit;
- Label3: TLabel;
- Edit3: TEdit;
- Label4: TLabel;
- Edit4: TEdit;
- Label5: TLabel;
- Edit5: TEdit;
- CheckBox1: TCheckBox;
- BitBtn1: TBitBtn;
- OpenDialog1: TOpenDialog;
- BitBtn2: TBitBtn;
- Image1: TImage;
- Image2: TImage;
- BitBtn3: TBitBtn;
- BitBtn4: TBitBtn;
- procedure FormCreate(Sender: TObject);
- procedure BitBtn1Click(Sender: TObject);
- procedure BitBtn2Click(Sender: TObject);
- procedure BitBtn3Click(Sender: TObject);
- procedure BitBtn4Click(Sender: TObject);
- private
- { Private declarations }
- public
- procedure AddIconToIEExt;
- { Public declarations }
- end;
- var
- Form1: TForm1;
- implementation
- {$R *.dfm}
- procedure TForm1.FormCreate(Sender: TObject);
- begin
- OpenDialog1.InitialDir:=ExtractFileDir(Application.ExeName);
- OpenDialog1.FileName:='';
- end;
- procedure TForm1.BitBtn1Click(Sender: TObject);
- begin
- With OpenDialog1 do
- begin
- OpenDialog1.FilterIndex:=1;
- OpenDialog1.FileName:='';
- if Execute then
- begin
- if (ExtractFileExt(OpenDialog1.FileName)='.exe') then
- Edit3.Text:=OpenDialog1.FileName;
- end;
- end;
- end;
- procedure TForm1.BitBtn2Click(Sender: TObject);
- begin
- With OpenDialog1 do
- begin
- OpenDialog1.FilterIndex:=2;
- OpenDialog1.FileName:='';
- if Execute then
- begin
- if (ExtractFileExt(OpenDialog1.FileName)='.ico') then
- begin
- Edit4.Text:=OpenDialog1.FileName;
- image1.Picture.LoadFromFile(OpenDialog1.FileName);
- end;
- end;
- end;
- end;
- procedure TForm1.BitBtn3Click(Sender: TObject);
- begin
- With OpenDialog1 do
- begin
- OpenDialog1.FilterIndex:=2;
- OpenDialog1.FileName:='';
- if Execute then
- begin
- if (ExtractFileExt(OpenDialog1.FileName)='.ico') then
- begin
- Edit5.Text:=OpenDialog1.FileName;
- image2.Picture.LoadFromFile(OpenDialog1.FileName);
- end;
- end;
- end;
- end;
- procedure TForm1.AddIconToIEExt;
- var
- Reg:TRegistry;
- begin
- Reg:=TRegistry.Create;
- try
- Reg.RootKey:=HKEY_LOCAL_MACHINE;
- if Reg.OpenKey('SoftwareMicrosoftInternet ExplorerExtensions{FB5F1910-F110-11d2-BB9E-00C04F795683}',True)then
- begin
- Reg.WriteString('CLSID','{1FBA04EE-3024-11D2-8F1F-0000F87ABD16}');
- Reg.WriteString('Exec',Edit3.Text);
- Reg.WriteString('HotIcon',Edit4.Text);
- Reg.WriteString('Icon',Edit5.Text);
- Reg.WriteString('ButtonText',Edit1.Text);
- Reg.WriteString('MenuText',Edit2.Text);
- if CheckBox1.Checked then
- Reg.WriteString('Default Visible','Yes')
- else
- Reg.WriteString('Default Visible','No');
- end;
- finally
- Reg.Closekey;
- Reg.Free;
- end;
- end;
- procedure TForm1.BitBtn4Click(Sender: TObject);
- begin
- if ((Edit1.Text='') or(Edit2.Text='')or
- (Edit3.Text='') or(Edit4.Text='')or (Edit5.Text=''))then
- ShowMessage('请设置好全部参数后,再进行尝试!')
- else
- begin
- AddIconToIEExt;
- ShowMessage('扩展对象信息成功写入注册表!')
- end;
- end;
- end.
- {
- ['{7F373309-E50F-4C08-9F78-D1E2AF454DB6}']
- {['{1FAD3C6B-666B-4C62-B632-A50E76DF1B70}'] }