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;
|
||||
|
||||
DISPID dispid;
|
||||
hr = winEx->GetDispID(name.data(), fdexNameEnsure, &dispid);
|
||||
CComBSTR bname = name.c_str();
|
||||
hr = winEx->GetDispID(bname, fdexNameEnsure, &dispid);
|
||||
|
||||
if (FAILED(hr))
|
||||
return;
|
||||
|
@ -307,14 +307,11 @@ DECLARE_API void html_eval(void *web, const wchar_t *js)
|
||||
if (FAILED(pDocument->get_Script(&scriptDispatch)))
|
||||
return;
|
||||
DISPID dispid;
|
||||
BSTR evalStr = SysAllocString(L"eval");
|
||||
CComBSTR evalStr = L"eval";
|
||||
if (scriptDispatch->GetIDsOfNames(IID_NULL, &evalStr, 1,
|
||||
LOCALE_SYSTEM_DEFAULT, &dispid) != S_OK)
|
||||
{
|
||||
SysFreeString(evalStr);
|
||||
|
||||
return;
|
||||
}
|
||||
SysFreeString(evalStr);
|
||||
|
||||
DISPPARAMS params;
|
||||
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;
|
||||
auto eval = std::make_unique<wchar_t[]>(n);
|
||||
_snwprintf(eval.get(), n, L"%s%s%s", prologue, js, epilogue);
|
||||
arg.bstrVal = SysAllocString(eval.get());
|
||||
if (scriptDispatch->Invoke(
|
||||
dispid, IID_NULL, 0, DISPATCH_METHOD,
|
||||
¶ms, &result, &excepInfo, &nArgErr) != S_OK)
|
||||
{
|
||||
SysFreeString(arg.bstrVal);
|
||||
return;
|
||||
}
|
||||
SysFreeString(arg.bstrVal);
|
||||
CComBSTR bstrVal = eval.get();
|
||||
arg.bstrVal = bstrVal;
|
||||
scriptDispatch->Invoke(
|
||||
dispid, IID_NULL, 0, DISPATCH_METHOD,
|
||||
¶ms, &result, &excepInfo, &nArgErr);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user