• 取得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;
    }
    

      

  • 相关阅读:
    qt教程
    linux shell 教程
    CMakeList.txt学习
    tx2上直接编译带contrib cuda的opencv
    tx2 opencv交叉编译后的对应文件的放置位置
    opencv4.1.0 交叉编译遇到的问题
    docker 学习
    c++ 类注意点
    数据库整理(五)数据库编程 触发器 事务 过程
    数据库整理(四)数据库安全性与完整性
  • 原文地址:https://www.cnblogs.com/jevan/p/2284302.html
Copyright © 2020-2023  润新知