笔下有余

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

IHTMLDocument2   *spDoc   =   NULL;

bool   __stdcall   CrnRunJavaScript(IHTMLDocument2   *spDoc,   LPSTR   lpScript,   LPSTR   lpLang   =   "JScript");

bool   __stdcall   CrnRunJavaScript(IHTMLDocument2   *spDoc,   LPSTR   lpScript,   LPSTR   lpLang)
  {
          IHTMLWindow2   *pWin;
          VARIANT   vRet;
          bool   bRet   =   false;
          Form1->CppWebBrowser1->Document->QueryInterface(
                                  ::IID_IHTMLDocument2,   reinterpret_cast<void**>(&spDoc));
          if(spDoc   !=   NULL)
          {  
                  try  
                  {
                          spDoc->get_parentWindow(&pWin);  
                          if(pWin   !=   NULL)
                          {  
                                  try
                                  {  
                                          pWin->execScript(WideString(lpScript),   WideString(lpLang),   &vRet);  
                                          bRet   =   true;  
                                  }  
                                  __finally  
                                  {  
                                          pWin   =   NULL;  
                                  }  
                          }  
                  }  
                  __finally
                  {  
                          spDoc   ==   NULL;  
                  }  
          }
          return   bRet;
  }


 

posted on 2009-12-15 14:15  笔下有余  阅读(1513)  评论(0)    收藏  举报