用VC++对IE浏览器进行高级操作

————————————————以下为程序代码—————————————
------------WriteReg()函数的主要内容:-----------


void CTestView::WriteReg()
{
    //建立上下文菜单
    HKEY phkResult;
    LPCTSTR lpSubKey = "Software//Microsoft//Internet Explorer//MenuExt";
    if (ERROR_SUCCESS == RegCreateKeyEx(HKEY_CURRENT_USER, lpSubKey, 0, "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &phkResult, 0))
    {
      CString keyValue = GetAppPath() + "MySelf.htm";
      RegSetValue(phkResult, "我们自己的上下文菜单(&W)", REG_SZ, keyValue, keyValue.GetLength());
    }
    //建立工具菜单
    lpSubKey = "Software//Microsoft//Internet Explorer//Extensions//{32204547-1C47-11d5-A413-00A00CC191CF}";
    if (ERROR_SUCCESS == RegCreateKeyEx(HKEY_LOCAL_MACHINE, lpSubKey, 0, "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS,NULL,&phkResult,0))
    {
      HKEY hResult;
      RegOpenKeyEx(HKEY_LOCAL_MACHINE, lpSubKey, 0, KEY_ALL_ACCESS, &hResult);
      CString type = "{1FBA04EE-3024-11d2-8F1F-0000F87ABD16}";
      RegSetValueEx(hResult, "CLSID", 0, REG_SZ, (const unsigned char *)((LPCSTR)type), type.GetLength());
      type="&MyTest";  //MenuText
      RegSetValueEx( hResult, "MenuText", 0, REG_SZ, (const unsigned char *)((LPCSTR)type), type.GetLength());
      type="我们自己的测试程序";  //MenuStatusBar
      RegSetValueEx( hResult, "MenuStatusBar", 0, REG_SZ, (const unsigned char *)((LPCSTR)type), type.GetLength()); 0
      type=GetAppPath()+"Test.exe";  //Exec
      RegSetValueEx( hResult, "Exec", 0, REG_SZ, (const unsigned char *)((LPCSTR)type), type.GetLength());
        
      //工具栏按钮
      type="MyTest";  //ButtonText
      RegSetValueEx( hResult, "ButtonText", 0, REG_SZ, (const unsigned char *)((LPCSTR)type), type.GetLength());
      type=GetAppPath()+"//Test.exe,128";  //Icon
      RegSetValueEx( hResult, "Icon", 0, REG_SZ, (const unsigned char *)((LPCSTR)type), type.GetLength());
      type=GetAppPath()+"//Test.exe,128";  //HotIcon
      RegSetValueEx( hResult, "HotIcon", 0, REG_SZ, (const unsigned char *)((LPCSTR)type), type.GetLength());
      type="Yes";  //Default Visible
      RegSetValueEx( hResult, "Default Visible", 0, REG_SZ, (const unsigned char *)((LPCSTR)type), type.GetLength());
      RegCloseKey( hResult );
    }
}





------------GetAppPath()-----------------
CString CTestView::GetAppPath()
{
    TCHAR pathtemp[255];
    GetModuleFileName(NULL,pathtemp,255);
    CString path = pathtemp;
    int i = path.ReverseFind('//');
    path = path.Left(i+1);
    return path;
}


----------------MySelf.htm---------------

<HTML>
<SCRIPT LANGUAGE="JavaScript">
var op = new String("http://www.tsinghua.edu.cn/")
open(op)
</SCRIPT>
</HTML>




----------------text.exe----------------
void CIEcontext::AddContext()
{
    // TODO: Add your dispatch handler code here
    WinExec("c://test//debug//test.exe", SW_SHOW);
}



--------------修改后的MySelf.htm------------
<HTML>
<SCRIPT language="VBScript">
set IeP=CreateObject("AddIEFun.IEcontext")
if err<>0 then
    msgbox("错误!")
else
    IeP. AddContext()
end if
</SCRIPT>
</HTML>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值