As Any in 64 bit systems.

ChrisO

Registered User.
Local time
Today, 18:07
Joined
Apr 30, 2003
Messages
3,202
As Any in 64 bit systems.

In the following API call does As Any also translate to a 64 bit system?

Code:
Private Declare Sub RtlMoveMemory Lib "kernel32" (ByRef Destination As Any, _
                                                  ByRef Source As Any, _
                                                  ByVal Length As Long)

An extract from a Microsoft article at:- http://msdn.microsoft.com/en-us/library/office/aa165080(v=office.10).aspx
“Some DLL functions have arguments that can take different data types. The VBA Declare statements for these functions define these arguments as type Any. Calling a DLL function with arguments declared as Any can be perilous, because VBA does not perform any data type checking for you. If you want to avoid the hazards of passing arguments as Any, you can declare multiple versions of the same DLL function, each with a different name and a different data type.”

So, if the compile of the above API call is controlled by a 32/64 bit compiler directive, does the As Any get converted to the correct data type and length?

PtrSafe and Long to LongLong seem to be known but is As Any known? I can find nothing which specifically relates to the difference between As Any in a 32 bit system as opposed to a 64 bit system.

I think it needs testing but I can’t test it. I also think that, if it fails, it will fail very quickly.

Regards,
Chris.
 
Resolved, I think…

As ‘Any’ also appears in the newer Microsoft 64 bit declarations just as it did in the earlier 32 bit declarations.

As a guess:-
As ‘Any’ does not require any special knowledge of what is being passed because all it requires is the address of the starting byte of the variable. If the variable being passed appears to be an Object, it really isn’t. What is being passed is a pointer to an Object and that pointer is a variable. In a 32 bit system that pointer is 4 bytes in length and in a 64 bit system that pointer is 8 bytes in length. It is therefore up to the API call to ‘know’ which system, 32/64 bit, it is running under. That should also include any padding required across memory boundaries in either system.

As such, ‘Any’, the address of the starting byte, is valid for both 32 and 64 bit versions irrespective of the length of the variable being passed.

Chris.
 

Users who are viewing this thread

Back
Top Bottom