⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 用vc++对ie浏览器进行高级操作.txt

📁 用VC++对IE浏览器进行高级操作ssss
💻 TXT
字号:
■ 用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>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -