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

推荐订阅源

F
Fortinet All Blogs
Attack and Defense Labs
Attack and Defense Labs
V2EX - 技术
V2EX - 技术
O
OpenAI News
S
Secure Thoughts
H
Heimdal Security Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Schneier on Security
Schneier on Security
H
Hacker News: Front Page
S
Security Affairs
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Vercel News
Vercel News
Microsoft Security Blog
Microsoft Security Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
P
Proofpoint News Feed
The Register - Security
The Register - Security
GbyAI
GbyAI
Cloudbric
Cloudbric
MongoDB | Blog
MongoDB | Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
K
Kaspersky official blog
Forbes - Security
Forbes - Security
Y
Y Combinator Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
Scott Helme
Scott Helme
Hacker News - Newest:
Hacker News - Newest: "LLM"
The Cloudflare Blog
Recorded Future
Recorded Future
人人都是产品经理
人人都是产品经理
Cyberwarzone
Cyberwarzone
C
CERT Recently Published Vulnerability Notes
Webroot Blog
Webroot Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
L
LangChain Blog
T
Tor Project blog
Microsoft Azure Blog
Microsoft Azure Blog
博客园_首页
Hacker News: Ask HN
Hacker News: Ask HN
Blog — PlanetScale
Blog — PlanetScale
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
B
Blog RSS Feed
N
News and Events Feed by Topic
阮一峰的网络日志
阮一峰的网络日志
I
Intezer
V
V2EX
T
Tailwind CSS Blog
SecWiki News
SecWiki News
NISL@THU
NISL@THU
C
Check Point Blog

博客园 - Sephil

[小技巧] 倍数的向上取整和向下取整 WTL汉化版 Delphi 与 VC 共享接口和对象 DelphiXE泛型不能用类类型做为约束的另类解决方案 百度音乐下载工具 (最后更新: 2012-7-20) 为Delphi应用增加脚本支持 插件框架Extensible Framework for Delphi DirectUI for Delphi VC CListCtrl 第一列列宽自适应 WriteFile写磁盘扇区是87错误的原因 批量更改文件名的批处理文件 替代Windows运行功能的工具FastRun BCB/Delphi2007 隐藏任务栏图标 OGA & WGA Crack 所有小工具 迅雷/快车/旋风地址转换器 oracle ora-01033和ora-00600错误 数独游戏 SudokuPuzzle 将文件夹映射为驱动器的工具
关于 API 中返回字串的一些问题
Sephil · 2009-05-24 · via 博客园 - Sephil

这几天在写个东西,其中有个函数,有这么几句

Code

但是调试发现FullPath总是得于PathName,就是说ExtNames[i]没被加上。。。

花了2小时才发现问题。原来PathName是调用ExpandEnvironmentStrings得到的

Code

查MSDN发现,ExpandEnvironmentStrings返回的长度是包括了\0的。。。

所以返回的结果最后有个\0,不管你在后面加什么,编译器都认为字符串到\0就结束了,这就是问题所在

只要这么改下就好了

Result.SetLength(::ExpandEnvironmentStrings(PathName.c_str(), &Result[1], MAX_PATH) - 1);

其他如GetSystemDirectory返回的长度是不变包括\0的,所以没这个问题

把这个记下来,免得到时候自己忘了