mirror of
https://github.com/HIllya51/LunaTranslator.git
synced 2025-01-13 07:33:53 +08:00
.
This commit is contained in:
parent
905fe2b819
commit
45294aaa3d
@ -1050,7 +1050,8 @@ void AddCustomObject(IHTMLDocument2 *doc, IDispatch *custObj, std::wstring name)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
DISPID dispid;
|
DISPID dispid;
|
||||||
hr = winEx->GetDispID(name.data(), fdexNameEnsure, &dispid);
|
CComBSTR bname = name.c_str();
|
||||||
|
hr = winEx->GetDispID(bname, fdexNameEnsure, &dispid);
|
||||||
|
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
return;
|
return;
|
||||||
|
@ -307,14 +307,11 @@ DECLARE_API void html_eval(void *web, const wchar_t *js)
|
|||||||
if (FAILED(pDocument->get_Script(&scriptDispatch)))
|
if (FAILED(pDocument->get_Script(&scriptDispatch)))
|
||||||
return;
|
return;
|
||||||
DISPID dispid;
|
DISPID dispid;
|
||||||
BSTR evalStr = SysAllocString(L"eval");
|
CComBSTR evalStr = L"eval";
|
||||||
if (scriptDispatch->GetIDsOfNames(IID_NULL, &evalStr, 1,
|
if (scriptDispatch->GetIDsOfNames(IID_NULL, &evalStr, 1,
|
||||||
LOCALE_SYSTEM_DEFAULT, &dispid) != S_OK)
|
LOCALE_SYSTEM_DEFAULT, &dispid) != S_OK)
|
||||||
{
|
|
||||||
SysFreeString(evalStr);
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
SysFreeString(evalStr);
|
|
||||||
|
|
||||||
DISPPARAMS params;
|
DISPPARAMS params;
|
||||||
VARIANT arg;
|
VARIANT arg;
|
||||||
@ -330,13 +327,9 @@ DECLARE_API void html_eval(void *web, const wchar_t *js)
|
|||||||
int n = wcslen(prologue) + wcslen(epilogue) + wcslen(js) + 1;
|
int n = wcslen(prologue) + wcslen(epilogue) + wcslen(js) + 1;
|
||||||
auto eval = std::make_unique<wchar_t[]>(n);
|
auto eval = std::make_unique<wchar_t[]>(n);
|
||||||
_snwprintf(eval.get(), n, L"%s%s%s", prologue, js, epilogue);
|
_snwprintf(eval.get(), n, L"%s%s%s", prologue, js, epilogue);
|
||||||
arg.bstrVal = SysAllocString(eval.get());
|
CComBSTR bstrVal = eval.get();
|
||||||
if (scriptDispatch->Invoke(
|
arg.bstrVal = bstrVal;
|
||||||
dispid, IID_NULL, 0, DISPATCH_METHOD,
|
scriptDispatch->Invoke(
|
||||||
¶ms, &result, &excepInfo, &nArgErr) != S_OK)
|
dispid, IID_NULL, 0, DISPATCH_METHOD,
|
||||||
{
|
¶ms, &result, &excepInfo, &nArgErr);
|
||||||
SysFreeString(arg.bstrVal);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
SysFreeString(arg.bstrVal);
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user