取得IE,然后运行本地JS

void EnumIE( void )
{
	CString jscript="function Vote(id,position) {if(datelimit()){$get(\"dropdownlistPosition\").value=(position==\"0\")?\"\":position; $get(\"dropdownlistPosition\").disabled=true;  $get(\"inputHiddenHideId\").value=id;$get(\"buttonVoteTemp\").click();} else {alert(\"投票暂停!\");}};\
					function OnCheckValidateCode(result){ switch(result) {case \"cookie\":alert(\"浏览器需允许Cookie!\"); return; break;case \"error\":return;default: return SaveRecord(\"SAVE\");break; }};\
					function OnVote(result)  { switch(result) {case \"false\": alert(\"投票失败!\"); break; case \"popedom\": alert(\"今天已达投票10次限制!\"); break; default: NewValidateCode(); $get(\"inputValidateCode\").value=\"\"; __doPostBack('buttonRefreshGridView','');  ResetForm(); break; }};\
					function getCookie(name){    var arr = document.cookie.match(new RegExp(\"(^| )\"+name+\"=([^;]*)(;|$)\"));     if(arr != null) return unescape(arr[2]); return null;};\
					Vote('755','38');$get(\"inputValidateCode\").value=getCookie(\"ValidateCode\");SaveAndClose();";
//Vote('149','0') 挂公司
	CComPtr< IShellWindows > spShellWin;
	HRESULT hr = spShellWin.CoCreateInstance( CLSID_ShellWindows );
	if ( FAILED ( hr ) )
	{
		return;
	}
 
	long nCount = 0;		// 取得浏览器实例个数(Explorer 和 IExplorer)
	spShellWin->get_Count( &nCount );
	if( 0 == nCount )
	{
		return;
	}
 
	for(int i=0; i<nCount; i++)
	{
		CComPtr< IDispatch > spDispIE;
		hr=spShellWin->Item(CComVariant( (long)i ), &spDispIE );
		if ( FAILED ( hr ) )	continue;
 
		CComQIPtr< IWebBrowser2 > spBrowser = spDispIE;
		if ( !spBrowser )		 continue;
 
		CComPtr < IDispatch > spDispDoc;
		hr = spBrowser->get_Document( &spDispDoc );
		if ( FAILED ( hr ) )	continue;
 
		CComQIPtr< IHTMLDocument2 > spDocument2 = spDispDoc;
		if ( !spDocument2 ) 	   continue;
 
		// 程序运行到此,已经找到了 IHTMLDocument2 的接口指针
		
		IHTMLWindow2 *pWindow;
		hr=spDocument2->get_parentWindow(&pWindow);
		if( ! pWindow)	continue;
		
		VARIANT ret;
		ret.vt=VT_EMPTY;
		VARIANT pVal;
		hr=pWindow->execScript(CComBSTR(jscript),L"javascript",&pVal);
 
	}
	spShellWin=NULL;
}

  

转载于:https://www.cnblogs.com/jevan/archive/2011/12/11/2284302.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值