O'Reilly logo

VB Shell Programming by J.P. Hamilton

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Appendix B. Pointers

CopyMemory is used a great deal throughout the course of this book to copy memory from one location to another. Without this function, it would be impossible to use pointers in Visual Basic. Since the function does exist, it is possible to write some very dangerous VB code. A short course on CopyMemory and pointers is definitely in order.

CopyMemory

There is really no function called CopyMemory. CopyMemory is merely an alias for the Win32 function RtlMoveMemory. Bruce McKinney, the author of Hardcore Visual Basic (Microsoft Press), was probably the first to use the alias CopyMemory. Now it is quite common to see RtlMoveMemory declared in this fashion. Its syntax (as reflected in a Visual Basic Declare statement) is:

Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" _ 
    (pDest As Any, pSource As Any, ByVal ByteLen As Long)

where pDest is a pointer to the starting target address to which data is to be copied, pSource is a pointer to the starting address from which data is to be copied, and ByteLen is the number of bytes to be copied.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required