MoveMemory

MoveMemory

MoveMemory複製記憶體。

函式原型為voidMoveMemory(PVOID Destination, const VOID*Source, SIZE_T Length)。

基本介紹

  • 外文名:MoveMemory
  • Destination:目的數據的地址
  • Source:來源數據的地址
  • Length:複製數據的位元組數
函式參數,套用舉例,

函式參數

MoveMemory各參數意義:
(1)Destination:目的數據的地址;
(2)Source:來源數據的地址;
(3)Length:複製數據的位元組數。

套用舉例

使用實例:
var rect1,RECT2:TRect;
begin
rect1.Left:=10;
rect1.Top:=10;
rect1.Bottom:=200;
rect1.Right:=200;
rect2.Left:=50;
rect2.top:=100;
rect2.Bottom:=400;
rect2.Right:=390;
form1.Canvas.FillRect(rect1);
showmessage('movemory!');
form1.Refresh;
windows.MoveMemory(@rect1,@rect2,sizeof(TRect));
form1.Canvas.FillRect(rect1);
結果把rect2的值賦到rect1中
移動數組的值
一般的辦法:
var s1,s2:array[0..4] of integer;
i:integer;
begin
s1[0]:=1;
s1[1]:=2;
s1[2]:=3;
s1[3]:=4;
s1[4]:=5;
s2[0]:=6;
s2[1]:=7;
s2[2]:=8;
s2[3]:=9;
s2[4]:=0;
for a:=0 to 4 do s1[a]:=s2[a];
end;
用movemeory的辦法:
var s1,s2:array[0..4] of integer;
i:integer;
begin
s1[0]:=1;
s1[1]:=2;
s1[2]:=3;
s1[3]:=4;
s1[4]:=5;
s2[0]:=6;
s2[1]:=7;
s2[2]:=8;
s2[3]:=9;
s2[4]:=0;
for i:=0 to 4 do showmessage('s1的'+inttostr(i)+':'+inttostr(s1[i]));
showmessage('movemeory1!');
windows.MoveMemory(@s1,@s2,sizeof(s1));
for i:=0 to 4 do showmessage('s1的'+inttostr(i)+':'+inttostr(s1[i]));
VB :
Declare Sub MoveMemory Lib "kernel32" Alias "RtlMoveMemory" (pDest As Any, pSource As Any, ByVal dwLength As Long)
'MoveMemory(pDest As Any, pSource As Any, ByVal dwLength As Long)
'MoveMemory參數意義:
'(1)pDest:目的數據的地址;
'(2)pSource:來源數據的地址;
'(3)dwLength:數據的位元組數;

相關詞條

熱門詞條

聯絡我們