jacob-project icon indicating copy to clipboard operation
jacob-project copied to clipboard

What's the difference between invoke() and call()?

Open HelloBush opened this issue 3 years ago • 1 comments

Hi , thanks for this fabulous project. I hava a question which may be a little silly .I noticed that there are two ways using dll's function by Jacob,but what's exactly the difference between invoke() and call()?Or which way is suggested in certain situation?

HelloBush avatar Dec 29 '21 12:12 HelloBush

Hello @HelloBush call(), get() and put() are more readable ways eventual underlying triggers of invoke(), as you can see for example there :

  • https://github.com/freemansoft/jacob-project/blob/f20f5c46f992ad7e19a5864dc320fcdac913a998/src/com/jacob/com/Dispatch.java#L453
  • https://github.com/freemansoft/jacob-project/blob/f20f5c46f992ad7e19a5864dc320fcdac913a998/src/com/jacob/com/Dispatch.java#L788
  • https://github.com/freemansoft/jacob-project/blob/f20f5c46f992ad7e19a5864dc320fcdac913a998/src/com/jacob/com/Dispatch.java#L580

The only case when this makes a difference is when an error occurs during the invoke trigger, indeed, the last argument of invoke is an array of the same size of the Sub parameters array, and provide you error code on which parameter was bad during the call.

let's say it would be better to use it, but these errors are caught anyway and we send the user a generic error, that's the reason why most of the pople ignore them by using call, get and put (it does not mean it is a good idea :D )

Zzirconium avatar Feb 08 '22 17:02 Zzirconium