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.d ll,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.d ll,2″, “HotIcon”);
//内容
CString strDo = lpDo;
if (strDo.IsEmpty()) strDo = “http://www.google.com/“;
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;
}
>> 本文固定链接: http://www.vcgood.com/archives/1029