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;
}
浙公网安备 33010602011771号