Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

function cannot be called. #126

Open
GoodZivi opened this issue May 6, 2023 · 3 comments
Open

function cannot be called. #126

GoodZivi opened this issue May 6, 2023 · 3 comments

Comments

@GoodZivi
Copy link

GoodZivi commented May 6, 2023

Hi,I am a beginner.I had a problem using winax.Could you help me please.
Here is my code.

var winax = require('winax');
var myObj = new winax.Object('MFCACTIVEXCONTRO.MFCActiveXControl1Ctrl.1');
console.log(myObj)

Terminal output.

<ref *1> [Function: undefined] Dispatch {
  [__vars]: {},
  [__methods]: {
    AboutBox: { name: 'AboutBox', dispid: -552, invkind: 1, flags: 0, argcnt: 0 },
    multiply: { name: 'multiply', dispid: 1, invkind: 1, flags: 0, argcnt: 2 }
  },
  [__type]: [
    { name: 'AboutBox', dispid: -552, invkind: 1, flags: 0, argcnt: 0 },
    { name: 'multiply', dispid: 1, invkind: 1, flags: 0, argcnt: 2 }
  ],
  [__value]: [Circular *1],
  [__id]: 'MFCACTIVEXCONTRO.MFCActiveXControl1Ctrl.1'
}

I cannot call the function like this.How to call 'multiply' function?

var winax = require('winax');
var myObj = new winax.Object('MFCACTIVEXCONTRO.MFCActiveXControl1Ctrl.1');
console.log(myObj.multiply(3,5))

Terminal output

console.log(myObj.multiply(3,5))
                  ^

Error: DispInvoke: multiply    catastrophic failure

    at Dispatch.<anonymous> (<anonymous>)
    at Object.<anonymous> (D:\Items\test\a.js:3:19)
    at Module._compile (node:internal/modules/cjs/loader:1254:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
    at Module.load (node:internal/modules/cjs/loader:1117:32)
    at Module._load (node:internal/modules/cjs/loader:958:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:23:47 {
  errno: -2147418113
}

Am i use it incorrectly?
At last, I am so sorry for my poor English.

@durs
Copy link
Owner

durs commented May 8, 2023

That's right, but weird, Catastrophic Failure (Error 0x8000FFFF) occurs when calling DispInvoke with dispid=1

@GoodZivi
Copy link
Author

GoodZivi commented May 8, 2023

Hi,durs.
According to the question I search.I think I have found the reason.
Before Ole4.0,External programs can directly call methods in OCX. After Ole4.0, every time a method in a control is called, the system will automatically check whether it is allowed to be called, that is, run 'COleControl. IsInvokeAllowed (DISPID)'

This method checks whether the control is properly initialized or loaded through a persistent storage interface. If one of the two conditions is met, it returns TRUE, otherwise it returns FALSE.

When using controls in MFC, many details, such as initialization, are filtered out, so that most users will not encounter this problem.

But when I call the function in node, it return false.

The solution is to overwrite this method again
like this:
'''
BOOL CMyNameCtrl::IsInvokeAllowed (DISPID)
{

  return TRUE;

}
'''
This work is difficult for me, because the ocx file is provided by another corporation.Finally, I changed my approach to solving this matter without node.

@minkee-lee
Copy link

Dear @GoodZivi,
I got the same issue and your research gave me an understanding. Thank you.
But this is still problem for me. So did you find the another solution ? Then could you share how to?
Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants