通过在注册表中添家内容实现
CString HelperIEE::guid()
{
CString sGuid;
GUID gguid = {0};
if (S_OK == ::CoCreateGuid(&gguid))
{
sGuid.Format("{%08X-%04X-%04x-%02X%02X-%02X%02X%02X%02X%02X%02X}",
gguid.Data1,
gguid.Data2,
gguid.Data3,
gguid.Data4[0], gguid.Data4[1],
gguid.Data4[2], gguid.Data4[3], gguid.Data4[4],
gguid.Data4[5], gguid.Data4[6], gguid.Data4[7]
);
}
return sGuid;
}
int HelperIEE::
addIEButton(
LPCSTR lpDo,
LPCSTR lpButtonText,
LPCSTR lpIcon, LPCSTR lpHotIcon,
LPCSTR lpMenuText, LPCSTR lpMenuStatusBar
)
{
int nRet = 0;
CString sKeyName;
sKeyName = "Software\\Microsoft\\Internet Explorer\\Extensions";
sKeyName += "\\";
sKeyName += guid();
CRegKey reg;
if (ERROR_SUCCESS != reg.Create(HKEY_LOCAL_MACHINE, sKeyName))
return nRet;
//固定的CLSID/不清楚到底是MS的什么东东
reg.SetValue("{1FBA04EE-3024-11D2-8F1F-0000F87ABD16}", "CLSID");
reg.SetValue("Yes", "Default Visible");
//提示
if (NULL != lpButtonText)
reg.SetValue(lpButtonText, "ButtonText");
else
reg.SetValue("addIEButton", "ButtonText");
//图标
if (NULL != lpIcon)
reg.SetValue(lpIcon, "Icon");
else
reg.SetValue(",2", "Icon");
//reg.SetValue("%SystemRoot%\\system32\\user32.dll,1", "Icon");
//reg.SetValue("c:\\test.ico", "Icon");
if (NULL != lpHotIcon)
reg.SetValue(lpHotIcon, "HotIcon");
else
reg.SetValue(path() + ",1", "HotIcon");
//reg.SetValue("%SystemRoot%\\system32\\user32.dll,2", "HotIcon");
//内容
CString strDo = lpDo;
if (strDo.IsEmpty()) strDo = "";
CString strDoUp = strDo;
strDoUp.MakeUpper();
if (strDoUp.Right(4) == _T(".HTM") || strDoUp.Right(5) == _T(".HTML"))
reg.SetValue(strDo, "Script");
else
reg.SetValue(strDo, "Exec");
//菜单
if (NULL != lpMenuText)
reg.SetValue(lpMenuText, "MenuText");
else
reg.SetValue("do what you do|&MenuText", "MenuText");
if (NULL != lpMenuStatusBar)
reg.SetValue(lpMenuStatusBar, "MenuStatusBar");
else
reg.SetValue("do what you do|MenuStatusBar", "MenuStatusBar");
reg.Close();
return nRet = 1;
}
源代码压缩包(收藏)
将以下内容保存为uue文件即可用winzip打开使用
_=_
_=_ Part 001 of 001 of file HelperIEE.zip
_=_
begin 666 HelperIEE.zip
M4$L#!!0````(`"J#\2[2%[318@0``#\+```-````2&5L<&5R245%+F-P<*U5
;
ME2KMJ6D3J>J?2R-ME6[/E2KUT$,O_1!59\9@L"&I6L628=Z;WWOS>_/^6!1!
M$]HN]%JR+!BN6P´6Q+7A!#I8QQ9R`!H"/(9+$#!LW?>%3%H4Z?L83R:=23^Q
M´,,.3`@X´YOZ<":,N57EDB/5TX/!$´E`ZL+1/CQ;1>K8/M5].,<]L88F´`*M
M+N_V]X@8.%3L-5N*UFBUY4S:IV$:P!CKWE)],JAJ;*%IKX@1,;$<"!PX!<R/
M=B!_1M30,:UA2.8Q´A:4A!P?>X%!KUZLPVC]F%<=W66E$BWY;"9]3C<O$XBW
M]T`D!7N6,P(K4%?´XSDHM=CVCXB2W&&*7?!I,#S1.K5C[:C6:PY`%9P7+NFF
M-01\I;(´<0>9@0T;E@T/]`GD#_KM=HY:Y4!DE@6?K@C$F!Z78N<0AP1+´1**
M*0_BP´,B!O>Q´@66N<9ZCRBIG[U^JYX:44B<K*(=[H-J%50J$I(\J&-(+?BG
M#)I=LJ):H8&\B8YY[GRKL´.<WRJ4V<^,_)2.Z1LMDN\EEZ->0@)"7<=Z,:DH
M)17;247YI##(@56Y.%C´E!*8[81<WF#S/(%YD9!?#IA)-IF0^>6RA%@.7DU&
M)JV;9DO>#3!&#L_,VT>2TNL"VZVC7%P1HGIPAA,;+0,Y.1")3829)@[J0"=@
MMB"
M´<OPD$]$56TY&´H.<2//7!MYT%-5>8:AXY,&][F8BV?$AZJNZ<)BI5K*(1Q^
M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