const
IE_EXT='/SoftWare/Microsoft/Internet Explorer/Extensions'; //把需要加到IE的程序加到这个目录下
IE_BAR='/SoftWare/Microsoft/Internet Explorer/ToolBar';
IE_GUID ='{1FBA04EE-3024-11D2-8F1F-0000F87ABD16}'; //必须的键值
IE_BAR_GUID='{1E796980-9CC5-11D1-A83F-00C04FC99D61}';
procedure IEBar(ID,IEHint,exe,HotIcon,ColdIcon,MenuText,MenuStatusBar: string);
Procedure DelIeBar(ID:String);
////////////////添加、删除IE工具栏图标过程///////////////
procedure IEBar(ID,IEHint,exe,HotIcon,ColdIcon,MenuText,MenuStatusBar: string);
var
i,p: integer;
buf: array[0..511] of Longword;
begin
try
with TRegistry.Create do begin
RootKey := HKEY_LOCAL_MACHINE;
OpenKey(IE_EXT,True);
CreateKey(ID);
OpenKey(IE_EXT+'/'+ID,True);
WriteString('ButtonText',IEHint);
WriteString('CLSID',IE_GUID);
WriteString('HotIcon',HotIcon);
WriteString('Icon',ColdIcon);
WriteString('Exec',Exe);
WriteString('Default visible','Yes');
WriteString('MenuText',MenuText); //IE工具菜单出现的文字
WriteString('MenuStatusBar',MenuStatusBar);
RootKey := HKEY_CURRENT_USER;
OpenKey(IE_EXT+'/CmdMapping',True);
i:=ReadInteger('NextId'); //最新ID
WriteInteger('NextId',i+1); //更新ID
WriteInteger(ID,i);
OpenKey(IE_BAR,True);
//for p:=0 to 511 do buf[p]:=0;
p:=ReadBinaryData(IE_BAR_GUID,buf,4096);
p:=p div sizeof(Longword);
buf[p]:=$420;
buf[p+1]:=$1e796980;
buf[p+2]:=$11d19cc5;
buf[p+3]:=$c0003fa8;
buf[p+4]:=$619dc94f;
buf[p+5]:=i;
buf[p+6]:=4;
WriteBinaryData(IE_BAR_GUID,buf,(p+7)*sizeof(Longword));
CloseKey;
Free;
end;
finally
end;
end;
//////////////删除IE工具栏图标的函数过程////////////////
Procedure DelIeBar(ID:String);
var
Reg:TRegistry;
begin
Reg:=TRegistry.Create;
try
Reg.RootKey := HKEY_LOCAL_MACHINE;
if reg.OpenKey('/Software/Microsoft/Internet Explorer/Extensions/',False) then
Reg.DeleteKey(Id);
reg.CloseKey ;
reg.Free;
except
Reg.CloseKey ;
Reg.Free ;
end;
end;
//////////////////////过程结束////////////////////////////
/////添加
procedure TFrmMain.button1Click(Sender: TObject);
var
S,P1,P2,P:String;
begin
S:=ExtractFilePath(application.exename);
P:=S+'notpad.exe';//你的exe文件
S:=S+'data/';
P1:=S+'***.ico';//你的图表文件
P2:=P1;
IEBar('{1dd88cc0-8b01-11d4-8c75-5254ab888ead}','我的测试',
P,P1,P2,'我的测试','我的测试');
end;