The functions of movememory and copymemory are similar. They both copy the memory and call the move process;
Movememory, copymemory operation pointer; move operation object.
Note that their parameter locations are different!
Example:
{Example 1} var buf1, buf2: array [0 .. 9] of ansichar; begin buf1: = '000000'; buf2: = 'abcdefghj'; move (buf2 [2], buf1 [4], 5); showmessage (buf1 ); {0123cdefg9} showmessage (buf2); {abcdefghij} end; {Example 2} var buf1, buf2: array [0 .. 9] of ansichar; begin buf1: = '000000'; buf2: = 'abcdefghj'; copymemory (@ buf2 [2], @ buf1 [4], 5 ); showmessage (buf1); {0123456789} showmessage (buf2); {ab45678hij} end; {Example 3} var S1, S2: tstringstream; {two string streams} begin S1: = tstringstream. create; S2: = tstringstream. create; {write to the first string stream} s1.writestring ('delphi blog in case '); showmessage (s1.datastring ); {In case of Delphi blog} {set the size of the second string stream} s2.setsize (6); {copy from the first stream to the second stream} copymemory (s2.memory, s1.memory, s2.size ); showmessage (s2.datastring); {In case} s1.free; s2.free; end;
This is only for testing. If tmemorystream, tstringstream, and other stream classes are used, their own replication operations are more convenient.