Thorsten Albers
8/31/2011 6:11:00 PM
Mayayana <mayayana@invalid.nospam> schrieb im Beitrag
<j3l99u$ela$1@dont-email.me>...
> I thought Thorsten was just being cranky.
No, he wasn't.
> The function
> is expecting a long numeric value that represents a memory
> address.
No, the function is expecting a memory address with a 'width' of 4 bytes of
memory. How these 4 bytes are passed to the function doesn't matter at all.
You may declare it 'As Any', 'As Long', 'As Single', pass a byte array with
4 elements, etc. CoTaskMemFree() doesn't know anything about what data type
it is in VB, it just reads 4 bytes from the stack and uses these as a
pointer.
And that is valid not only for CoTaskMemFree() but for any Declare
statement in VB:
You only have to ensure that
- the correct number of bytes is passed, and
- that the values of the bytes are correct.
The data type used with the Declare statement in VB is only a help for the
VB developer to pass the correct amount of bytes as well as the correct
byte values. With external functions there is no need that it is of the
same data type as used by the function.
--
Thorsten Albers
gudea at gmx.de