Windows API Guide: CB_DELETESTRING Message


Declare Sub CopyMemory Lib "kernel32.dll" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)

Platforms

  • Windows 95: Supported.
  • Windows 98: Supported.
  • Windows NT: Requires Windows NT 3.1 or later.
  • Windows 2000: Supported.
  • Windows CE: Not Supported.

Description & Usage

CopyMemory, as far as the Windows API is concerned, is perfectly identical to the MoveMemory function; in fact, they actually are the same function! CopyMemory moves the contents of a portion of memory from one location to another. The two locations are identified by pointers to the memory addresses. After the copy, the original contents in the source are set to zeros.

Return Value

CopyMemory does not return a value.

Visual Basic-Specific Issues

A pointer to any variable can be automatically generated merely be passing that variable as either Destination or Source. However, if either a String or a Long holding the desired memory address is passed, the ByVal keyword must preceed it.

Parameters

Destination
A pointer to the memory address to use as the target, which receives the transfered data.
Source
A pointer to the memory address to use as the source, which initially holds the data to be transfered.
Length
The number of bytes of data to copy from the source memory location to the target memory location.

Example

' This code is licensed according to the terms and conditions listed here. ' Transfer the contents of one byte array to another.  After the "copy", ' the contents of the source array are set to 0. Dim source(0 To 9) As Byte  ' source array of 10 bytes Dim target(0 To 9) As Byte  ' similarly sized target array Dim c As Integer  ' counter variable ' Fill the source array with some information. For c = 0 To 9  ' loop through each element   source(c) = c  ' set each element's value to its index Next c ' Transfer the data from the target array to the source array.  Note how pointers ' are implied merely by passing the arrays as usual. CopyMemory target(0), source(0), 10  ' copy all 10 bytes ' Verify that the contents were transfered. For c = 0 To 9   Debug.Print target(c);  ' this will now contain the information Next c

See Also

MoveMemory

Category

Memory

Go back to the alphabetical Function listing.
Go back to the Reference section index.


Last Modified: July 28, 1999
This page is copyright © 1999 Paul Kuliniewicz. Copyright Information
Go back to the Windows API Guide home page.
E-mail: vbapi@vbapi.com Send Encrypted E-Mail
This page is at http://www.vbapi.com/ref/c/copymemory.html



Windows API Guide
Windows API Guide - Reference - Volume 1: Version 3.0 For the MS-DOS and PC-DOS Operating Systems
ISBN: B001V0KQIY
EAN: N/A
Year: 1998
Pages: 610

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net