//使用 PChar^
var
p: PChar;
begin
p := PChar('abcd');
ShowMessage(p); {abcd}
ShowMessage(p^); {a}
p := p + 2;
ShowMessage(p^); {c}
Dec(p);
ShowMessage(p^); {b}
ShowMessage(p); {bcd}
end;
//遍历 PChar 中的字符
var
p: PChar;
begin
p := PChar('abcd');
while p^ <> #0 do
begin
ShowMessage(p^); {分别显示: a、b、c、d}
Inc(p);
end;
end;
//替代缓冲区与内存分配的简单方法
var
p: PChar;
begin
p := PChar(StringOfChar(#0, 255));
GetWindowsDirectory(p, 255); {譬如获取 Windows 目录}
ShowMessage(p); {C:\WINDOWS}
end;
posted on
2008-04-06 22:33
万一
阅读(4926)
评论(0)
编辑
收藏