IE BHO:区分JavaScript对象和功能

时间:2017-09-10 08:57:46

标签: c++ internet-explorer atl bho

我正在为Internet Explorer开发BHO。在BHO代码中,当我枚举JavaScript对象的属性时,我需要检测属性值是否是JavaScript函数。

我枚举对象属性,并将每个属性值作为Server listening on localhost:4000 **click on detailsBtn** GET /get/details?srv=myserver.google.com&script=%2Fusr%2Fbin%2Ftail 304 16.003 ms - - connect YyYHFI9CARpBHaxoAAAB **click on closeBtn** DISconnected YyYHFI9CARpBHaxoAAAB **click on detailsBtn** GET /get/details?srv=myserver.google.com&script=%2Fusr%2Fbin%2Ftail 304 6.308 ms - - connect vzfBnUPHUqYXd5qaAAAC connect vzfBnUPHUqYXd5qaAAAC **click on closeBtn** DISconnected vzfBnUPHUqYXd5qaAAAC DISconnected vzfBnUPHUqYXd5qaAAAC **click on detailsBtn** GET /get/details?srv=myserver.google.com&script=%2Fusr%2Fbin%2Ftail 304 4.677 ms - - connect 3quEe5G1gFDJ2BvrAAAD connect 3quEe5G1gFDJ2BvrAAAD connect 3quEe5G1gFDJ2BvrAAAD **click on closeBtn** DISconnected 3quEe5G1gFDJ2BvrAAAD DISconnected 3quEe5G1gFDJ2BvrAAAD DISconnected 3quEe5G1gFDJ2BvrAAAD 获取,如下所示:

VARIANT

对象和函数都是CComQIPtr<IDispatchEx> pObj = /* ... get a reference to JavaScript object */ DISPID dispId = DISPID_STARTENUM; for (; pObj && NOERROR == pObj->GetNextDispID(fdexEnumDefault, dispId, &dispId);) { DISPPARAMS dispParams = { 0 }; CComVariant value; // here I get property value // invoke property getter pObj->Invoke(dispId, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYGET, &dispParams, &value, NULL, NULL); // determine value kind switch (value.vt) { case VT_DISPATCH: // both Object and Function get here... } } 等于VARTYPE vt。我正在寻找区分两者的方法。

只是旁注

在JavaScript中,我可以这样做:

VT_DISPATCH

typeof obj === "function"

(虽然在IE中,Object.getPrototypeOf(obj).constructor.name === "function" constructor.name)。

0 个答案:

没有答案