当然是用别人的dll,
小弟想入门。

解决方案 »

  1.   

    www.codeproject.com 有这方面的例子
      

  2.   

    msdn中的script host就是这样的东西,
    ms 提供vbscript javascript的解释引擎,只要有ie你的系统中就有这样的引擎,
    如果你想自己写,可以,使用ms制订的引擎标准接口,或者去aparch找一个javascript的开放源码的引擎
      

  3.   

    JavaScript call from C++
    http://www.codeproject.com/com/JSCalls.aspHOWTO: Call a Script Function from a VC WebBrowser Application
    Get the IDispatch of the HTML document. 
    Call IDispatch::GetIDsOfNames to get the ID of the script function. 
    Call IDispatch::Invoke to execute the function. 
    The following Visual C++ source code demonstrates how to implement this in your own application. This code uses smart pointers created by the #import statement. You must include this #import statement in one of your source code files, preferably Stdafx.h: #import "C:\winnt\system32\mshtml.tlb" // location of mshtml.tlb   void CMyClass::ExecuteScriptFunction()
       {
          // m_WebBrowser is an instance of IWebBrowser2
          MSHTML::IHTMLDocument2Ptr spDoc(m_WebBrowser.GetDocument());      if (spDoc)
          {
             IDispatchPtr spDisp(spDoc->GetScript());
             if (spDisp)
             {
                // Evaluate is the name of the script function.
                OLECHAR FAR* szMember = L"evaluate";
                DISPID dispid;            HRESULT hr = spDisp->GetIDsOfNames(IID_NULL, &szMember, 1,
                                               LOCALE_SYSTEM_DEFAULT, &dispid);            if (SUCCEEDED(hr))
                {
                   COleVariant vtResult;
                   static BYTE parms[] = VTS_BSTR;               COleDispatchDriver dispDriver(spDisp);               dispDriver.InvokeHelper(dispid, DISPATCH_METHOD, VT_VARIANT,
                                           (void*)&vtResult, parms,
                                           "5+Math.sin(9)");
                }
             }
          }
       } The following is the HTML for the Web page that contains the evaluate function:<HTML>
      <HEAD>
        <TITLE>Evaluate</TITLE>    <SCRIPT>
          function evaluate(x)
          {
             alert("hello")
             return eval(x)
          }
       </SCRIPT>
      </HEAD>  <BODY>
      </BODY>
    </HTML> REFERENCES
    This source code is based on the Visual Basic sample that appears in the March/April 1998 edition of MSDN News. Please refer to this edition for information about how to execute a script function from a Visual Basic application that is hosting the WebBrowser control.
      

  4.   

    如果不用IE Browser Control,可以直接使用系统中的Javascript解释器吗?
    用了 IE Browser Control会使应用程序变得臃肿