//StrPas: 转换 PChar 为 string; 现在可以直接赋值, 很少用了.
var
  p: PChar;
  s: string;
begin
  p := 'Delphi';
  s := StrPas(p);
  ShowMessage(s); {Delphi}
end;

//StrNew、StrDispose: 建立与销毁 PChar. var p: PChar; begin p := StrNew('Delphi'); ShowMessage(p); {Delphi} StrDispose(p); end;
//StrFmt、StrLFmt: 针对 PChar 的格式化函数 var buf: array[0..255] of Char; p: PChar; begin p := StrFmt(buf, '%d, %d', [123, MaxInt]); ShowMessage(buf); {123, 2147483647} ShowMessage(p); {123, 2147483647} p := StrLFmt(buf, 9, '%d, %d', [123, MaxInt]); ShowMessage(buf); {123, 2147} ShowMessage(p); {123, 2147} end;
//StrNextChar; 因为 PChar 支持加减运算, 这个函数很少用 var p: PChar; begin p := '12345'; p := StrNextChar(p); ShowMessage(p); {2345} end;
//StrCharLength: 一个 Char 的长度 var p: PChar; i: Integer; begin p := 'Delphi'; i := StrCharLength(p); ShowMessage(IntToStr(i)); {1} end;
SysUtils 单元下的公用函数目录

posted on 2008-05-13 13:13  万一  阅读(8544)  评论(0编辑  收藏  举报