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

推荐订阅源

Martin Fowler
Martin Fowler
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
A
About on SuperTechFans
Apple Machine Learning Research
Apple Machine Learning Research
The Register - Security
The Register - Security
Vercel News
Vercel News
H
Hackread – Cybersecurity News, Data Breaches, AI and More
人人都是产品经理
人人都是产品经理
MyScale Blog
MyScale Blog
云风的 BLOG
云风的 BLOG
博客园_首页
U
Unit 42
T
Tailwind CSS Blog
G
GRAHAM CLULEY
F
Full Disclosure
V
Vulnerabilities – Threatpost
T
Tenable Blog
月光博客
月光博客
P
Privacy & Cybersecurity Law Blog
P
Privacy International News Feed
K
Kaspersky official blog
Scott Helme
Scott Helme
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
N
News and Events Feed by Topic
T
The Exploit Database - CXSecurity.com
N
News and Events Feed by Topic
有赞技术团队
有赞技术团队
Recent Commits to openclaw:main
Recent Commits to openclaw:main
L
LINUX DO - 最新话题
Recorded Future
Recorded Future
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Help Net Security
Help Net Security
The GitHub Blog
The GitHub Blog
Cisco Talos Blog
Cisco Talos Blog
SecWiki News
SecWiki News
P
Proofpoint News Feed
Security Latest
Security Latest
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
罗磊的独立博客
S
Security Affairs
M
MIT News - Artificial intelligence
L
LINUX DO - 热门话题
美团技术团队
Simon Willison's Weblog
Simon Willison's Weblog
T
Threat Research - Cisco Blogs
Stack Overflow Blog
Stack Overflow Blog
Forbes - Security
Forbes - Security
Hugging Face - Blog
Hugging Face - Blog
博客园 - Franky
V
Visual Studio Blog

博客园 - Haozes

新Blog 拼写检查算法 Golang 版 Windbg 离线调试.Net 程序入门 (译)你必须知道的位运算技巧 Low Level Bit Hacks You Absolutely Must Know Windows 下 命令行增强工具 WPF Layout & Image异步加载 几篇文章了解编译原理 WPF Binding Validation 数据验证 WPF 实现Loading效果 推荐一个.NET 命令行参数Parser 库 常用开发工具介绍 使用.Net Memory Profiler 分析.Net程序内存泄露 使用Mdbg.exe 调试.Net 程序 WPF 多语言方案 .Net 2 Tip :捕获CSE和Thread.Timer与Thread.Sleep比较 使用CSharp Driver操作Mongodb介绍 使用Python操作MSSQL数据库. 运行.Net4.0程序是否要安装之前的.Net版本 javascript Disable <div> or other tag in Other Browser like FF,Chrome
Delphi 无类型参数传递动态数组和静态数组
Haozes · 2010-12-01 · via 博客园 - Haozes

procedure TForm1.btn1Click(Sender: TObject);
var
verifyMsg :
array[0..48] of Char; //定长数组
signedLen : Integer;
verfyFile : TFileStream;
str :
string;
len : Integer;
begin
len :
= 48;
str :
= 'hello world';

FillChar(verifyMsg[

0], len, 0);
// OK
// FillChar(verifyMsg, len, 0);

CopyMemory(@verifyMsg[

0], PChar(@str[1]), Length(str)); //要从str[1] 开始copy
// OK
// CopyMemory(@verifyMsg, Pointer(str), Length(str)); //str pointer pchar都可以
// OK
// CopyMemory(@verifyMsg, @str[1], Length(str)); //要从str[1] 开始copy

verfyFile :

= TFileStream.Create('c:\\test.data', fmCreate or fmShareDenyRead);// 方法1 Ok
verfyFile.Write(verifyMsg[
0], Length(verifyMsg));
// 方法 2 OK
// verfyFile.Write(PChar(@verifyMsg[0])^, Length(verifyMsg));
// 方法 3 OK
// verfyFile.Write(verifyMsg, Length(verifyMsg));// 测试写入字符串
// 方法1 OK
// verfyFile.write(PChar(str)^,length(str));
// 方法 2 wrong
// 写入内容是错误的 可能是str的内部结构导致
// verfyFile.write(str, length(str));
// 方法 3 OK
// verfyFile.write(str[1], length(str));
// 方法 4 OK
// verfyFile.write(Pointer(str)^,length(str));

freeAndNil(verfyFile);

end;procedure TForm1.btn2Click(Sender: TObject);
var
verifyMsg :
array of Char; //动态数组
signedLen : Integer;
verfyFile : TFileStream;
str :
string;
len : Integer;
begin
len :
= 48;
str :
= 'hello world';
SetLength(verifyMsg, len);
// Error FillChar 参数不是指针,如下这行所以是错的.
// FillChar(verifyMsg, len, 0);
FillChar(verifyMsg[
0], len, 0);// OK 接收参数是指针
CopyMemory(@verifyMsg[
0], @str[1], Length(str));
// 要从str[1] 开始copy
// CopyMemory(verifyMsg, PChar(@str[1]), Length(str));
verfyFile :
= TFileStream.Create('c:\\test2.data', fmCreate or fmShareDenyRead);// 方法 1 OK 接收参数是无参类型
// verfyFile.Write(PChar(@verifyMsg[0])^, Length(verifyMsg));
// 方法 2 OK 接收参数是无参类型
verfyFile.Write(verifyMsg[
0], Length(verifyMsg));

freeAndNil(verfyFile);

end;