惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Simon Willison's Weblog
Simon Willison's Weblog
Help Net Security
Help Net Security
P
Privacy International News Feed
T
Threat Research - Cisco Blogs
C
Cisco Blogs
C
CERT Recently Published Vulnerability Notes
NISL@THU
NISL@THU
L
LINUX DO - 热门话题
Security Latest
Security Latest
A
Arctic Wolf
G
GRAHAM CLULEY
月光博客
月光博客
S
Securelist
D
Docker
J
Java Code Geeks
T
Troy Hunt's Blog
T
Tenable Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
SecWiki News
SecWiki News
S
Security @ Cisco Blogs
量子位
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
L
LINUX DO - 最新话题
Recent Commits to openclaw:main
Recent Commits to openclaw:main
aimingoo的专栏
aimingoo的专栏
博客园 - 【当耐特】
H
Heimdal Security Blog
The Hacker News
The Hacker News
博客园 - 三生石上(FineUI控件)
Application and Cybersecurity Blog
Application and Cybersecurity Blog
N
Netflix TechBlog - Medium
Vercel News
Vercel News
Forbes - Security
Forbes - Security
B
Blog RSS Feed
H
Hackread – Cybersecurity News, Data Breaches, AI and More
IT之家
IT之家
B
Blog
MongoDB | Blog
MongoDB | Blog
博客园 - 聂微东
Google DeepMind News
Google DeepMind News
S
Secure Thoughts
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
C
Check Point Blog
云风的 BLOG
云风的 BLOG
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
T
The Blog of Author Tim Ferriss
L
Lohrmann on Cybersecurity
F
Full Disclosure
D
Darknet – Hacking Tools, Hacker News & Cyber Security
P
Proofpoint News Feed

博客园 - sonicit

再写Javascript闭包 后台数据缓存的一点心得 C# 使用 Newtonsoft.Json 对DataTable转换中文乱码问题的解决 Vue 数据双向绑定的误区 关于JS Pormise的认识 关于jqGrid中GridUnload方法的困惑 Javascript异步编程的4种方法 SQLServer 获得所有表结构(包括表名及字段) ACE代码编辑器,代码提示,添加自定义数据 利用闭包向post回调函数传参数 在seajs中使用require加载静态文件的问题 jqGrid标题行与第一行之间有很大空白的问题解决。 关于bootstrapValidator提交问题的解决 心得(一) 使用心得(一) MSSQL获得表的字段名称及其参数 Controller_Abstract的改造 QeePHP View视图的默认变量与新增变量 Windows 7 安装VS2008 SP1 失败
Delphi 的内存操作函数(5): 复制内存
sonicit · 2014-09-07 · via 博客园 - sonicit

MoveMemory、CopyMemory 的功能类似, 都是复制内存, 都是调用 Move 过程;

MoveMemory、CopyMemory 操作指针; Move 操作实体.

还要注意, 它们的参数位置不一样!

{例1}
var
  buf1,buf2: array[0..9] of AnsiChar;
begin
  buf1 := '0123456789';
  buf2 := 'abcdefghij';

  Move(buf2[2], buf1[4], 5);

  ShowMessage(buf1); {0123cdefg9}
  ShowMessage(buf2); {abcdefghij}
end;

{例2}
var
  buf1,buf2: array[0..9] of AnsiChar;
begin
  buf1 := '0123456789';
  buf2 := 'abcdefghij';

  CopyMemory(@buf2[2], @buf1[4], 5);

  ShowMessage(buf1); {0123456789}
  ShowMessage(buf2); {ab45678hij}
end;

{例3}
var
  s1,s2: TStringStream; {两个字符串流}
begin
  s1 := TStringStream.Create;
  s2 := TStringStream.Create;

  {向第一个字符串流写入}
  s1.WriteString('万一的 Delphi 博客');
  ShowMessage(s1.DataString); {万一的 Delphi 博客}

  {设置第二个字符串流的大小}
  s2.SetSize(6);
  {从第一个流复制到第二个流}
  CopyMemory(s2.Memory, s1.Memory, s2.Size);
  ShowMessage(s2.DataString); {万一的}

  s1.Free;
  s2.Free;
end;

这里仅仅是为了测试, 如果真的使用 TMemoryStream、TStringStream 等流类, 它们自身提供的复制操作更方便.



转自《万一的Delphi博客》