PDA

View Full Version : Problem with formal parameters when COM component is called



xLeaves
05-08-2019, 13:08
I need to use a COM DLL to get the mouse position (of course, this function is not important, because many functions need to use formal parameters, just use this function to reproduce this problem).

The code called in VBScript is as follows:


Dim x, y
Dim dm
set dm = CreateObject("dm.dmsoft")
Call dm.GetCursorPos(x, y)
MsgBox x & "_" & y

It can get the results correctly. If you use a 64-bit operating system, you need to change the VBS runtime environment to 32-bit first.



Dim dm As iDispatch = NewCom("dm.dmsoft")
Dim As Long x, y
dm.GetCursorPos(x, y)
MsgBox(x & "_" & y)

The result is always 0, 0

ThinBasic can support some simple formal parameter passing, such as Byte, Int16, Int32, Int64, Single, Double, String, etc.

ErosOlmi
06-08-2019, 00:05
Is your COM server 64 bits?
thinBasic is not able to use it if 64 bits.

Otherwise if you can send me your com dll, I can make some tests registering it and see what I can do.
Mail: support at thinbasic dot com

There are many kind of COM servers. thinBasic is able to use them only if they expose dual interface.

Ciao
Eros

xLeaves
06-08-2019, 19:48
It is 32-bit

I have sent the DLL file to you by email.

Run the above code to reproduce the problem. Essentially, it is caused by formal parameters (data passing pointers).

ErosOlmi
06-08-2019, 21:05
Dear xLeaves,

I've analyzed you COM dll and it is OK.

The problem is that thinBasic is actually not able to call such a method because GetCursorPos accept 2 Variant variable passed BYREF.
Most of the other methods/properties seems ok.

I'm sorry about that ... I will see what I can do in future thinBasic versions.

Ciao
Eros


9984

xLeaves
06-08-2019, 21:11
thank you ErosOlmi:

In fact, the main function of this DLL is image recognition and text recognition.

Fortunately, it has a way to return a string (FindPicE).

Of course this reduces the speed of the function call.

But as a temporary solution is enough.

Thank you very much for your help, my IDE is still in progress.

These extensions are just a icing on the cake for ThinBasic.

ErosOlmi
06-08-2019, 21:18
To be able to be used in thinBasic, maybe you can add 2 new methods to your interface:

GetCursorX returning x position of the cursor

GetCursorY returning y position of the cursor