idobatter/node-win32ole

Returning errorcde 0x8000ffff when calling C++ ocx's method.

Opened this issue · 0 comments

I tried to use win32ole addon to load general activex controls except MS Office's
(Excel, Internet Explorer, etc..).
I encountered the problem that methods of C++ ocx cannot be called.
(VB ocx's did well.)

c:\Program Files\nodejs>node ntgraph.js
ProgID: NTGRAPH.NTGraphCtrl.1
clsid: c2 01 fe c9 46 27 9b 47 96 ab e0 be 99 31 b0 18
OLE error: [AboutBox] hr: 0x8000ffff [AboutBox] = [-552]
??邀?邀?邀?: ??邀?邀?邀?
(It always seems to be appeared at that time you mistake calling 'obj.get { ocv-

getProp() }' <-> 'obj.call { ocv->invoke() }'.) IDispatch::Invoke AutoWrap() failed

CoInitialize and CoCreateInstance were executed nornally.
But Inoke failed returning error code, 0x8000ffff (Catastrophic Failure).

At first, I inspected if initialization of automation process was wrong.
Later, I tested calling same method using VB script.

Set ntgraph = CreateObject("NTGRAPH.NTGraphCtrl.1")
XV = ntgraph.ElementXValue(0, 0)
MsgBox(CStr(XV))

Set ntgraph = Nothing

VB Script returned same error code, 0x8000ffff.
So, I thougt that the cause of failure is not from win32ole but from activex itself.
I found some article about 0x8000ffff error code
and knew that I have to modify the code of activex control.

https://support.microsoft.com/en-us/kb/189065#/en-us/kb/189065
When trying to use an ActiveX Control as an automation server, you need to override the method IsInvokeAllowed. For more information on why this method has to be overridden, please see the REFERENCES section below.

To fix the problem, override IsInvokeAllowed in your ActiveX Control as follows:

https://support.microsoft.com/en-us/kb/189065#/en-us/kb/189065
BOOL CMyOleControl::IsInvokeAllowed (DISPID dispid)
{

// You can check to see if COleControl::m_bInitialized is FALSE
// in your automation functions to limit access.
return TRUE;
}

When I added this code
VBscript returned successfully and win32ole as well.

Thanks.