VB Code:
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (ByVal lpDest As Long, ByVal lpSource As Long, ByVal nBytes As Long)
Notice how the params are now given "as long" rather than "as any". Since it ultimately uses a long value, you may as well cut out the fudgy "any" type. I have a function I made a long time ago to give me a VB string if I only knew the pointer, and it uses that particular style to avoid potential problems.
VB Code:
Private Declare Function lstrlen Lib "kernel32" Alias "lstrlenW" (ByVal lpString As Long) As Long
Private Function GetStringFromPointer(ByVal lpString As Long) As String
Dim lngLength As Long, strBuffer As String
lngLength = lstrlen(lpString) 'get length of string (in chars)
strBuffer = Space$(lngLength) 'make a buffer to copy to
CopyMemory StrPtr(strBuffer), lpString, lngLength * 2 'copy the string (note that this is a unicode string, so really there are 2 bytes per char
GetStringFromPointer = strBuffer 'return the copied string
End Function
'assume 1051 was your pointer, and you wanted the string
Dim strX As String
strX = GetStringFromPointer(1051)