Quote Originally Posted by Elroy View Post
And TomCatChina, you really should read through that link I gave you.

Even after you get the address of a procedure in an object, you can't just call it like a procedure in a BAS module.


Procedures in objects have an extra argument implicitly inserted in the call, and they also return their results differently than a function in a BAS module. So, both LaVolpe and me patch in a piece of machine code (i.e., a "thunk") to rearrange things so that you can call class methods just like BAS procedures.

There's really no other way to do it without a thunk.

-------------

And just a further FYI, VB6 (compiled or p-code) takes care of all of this under-the-hood. But, when you're using a custom "AddressOf" for an object's procedure, those issues are no longer taken care of.
A clas function address can be bound to a function in a module.
abc.exe module1.bas
Code:
function sum(this as long,a as.long,b as long,result  as long) as long
'asm code by writeprocessmemory
= call dll.class1.sum
end function

function sum2(this as long,a as.long,b as long,result  as long) as long
'asm code by writeprocessmemory
= call dll.class1.sum2
end function
If you develop a ActiveX. DLL yourself,
class1.cls
Code:
public sub test()
end sub

friendly function sum(a as.long,b as long) as long
sum=a+b
end function

private function sum2(a as.long,b as long) as long
sum2=a+b
end function
Call it in the ABC. Exe
get the address of the private /friendly function.
Some of the functions that can be implemented, you can put this air conditioner, these undocumented functions can be called by themselves.
To prevent unauthorized use of them.
At the same time, the speed of this method can be increased by 20 times.

If we call the export function in the standard DLL. The speed is dozens of times faster than calling the method of controlling the object.