複製鏈接
請複製以下鏈接發送給好友

CopyMemory

鎖定
CopyMemory是一個Windows API函數,它能將一塊內存數據從一個位置複製到另一個位置。
中文名
複製內存
外文名
CopyMemory
性    質
API函數
聲明位置
Windows.h
返回值
void

CopyMemory函數原型

VOID CopyMemory
PVOID Destination,
CONST VOID *Source,
SIZE_T Length

CopyMemory參數

Destination
要複製內存塊的目的地址。
Source
要複製內存塊的源地址。
Length
指定要複製內存塊的大小,單位為字節

CopyMemory返回值

該函數為VOID型,沒有返回值。

CopyMemory注意事項

如果目的塊與源塊有交疊,結果是不可預料的,使用MoveMemory可以解決這個問題。
使用環境
Windows NT:要求3.1或更高版本
Windows:要求windows 95或更高版本
Windows CE:不支持。
頭文件 winbase.h.
注意一點CopyMemory和MoveMemory不過是RtlMoveMemory的一個別名而已

CopyMemory示例代碼段

char szname[50]="陣雨";
char szfriend="polelf,oo";
CopyMemory( szname+4, szfriend, 10 );
OutputDebugString( szname );//輸出結果為"陣雨polelf,oo"

CopyMemoryvb6的聲明

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