You need this declaration:
Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (ByVal nDestination As Long, ByVal nSource As Long, ByVal Length As Long)
Notice the use of long instead of any. This is used since we are passing pointers, which are longs.
You need to observe the following rules:
1. Use Strptr to obtain the address of a string variable
2. Use Objptr to obtain the address of an object
3. Use Varptr to obtain the address of any other type of variable
4. Never attempt to copy to/from an uninitialized string.
5. Use fixed length strings where possible
Note about 4:
When a string is a destination ensure enough memory is allocated. If the string is a variable length string, initialize it using something like:
s = String$(Lenb(u), 0) where s is the variable length string and u is a UDT.
If the string is fixed length, memory is already allocated. Youmay want to still initialize it using something like:
s = String$(Lenb(s), 0)where s is the fixed length string
When a string is a source ensure the string has been assigned a value. Ensure that no more than the smaller of the two lengths is copied. You can use something like:
CopyMemory Varptr(u, Varptr(s), IIf(Lenb(u) < lenb(s), lenb(u), lenb(s)
where s is the string and u is a UDT.
I hope this helps,
SUN.
SUN