SysUtils.StrAlloc、SysUtils.StrBufSize

StrAlloc   : 给 PChar 指针分配空间, 并填充 #0;
StrBufSize : PChar 缓冲区大小.

 
 
 
 
 

 

 
  
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs;

type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
var
  p: PChar;
  i: Integer;
begin
  p := StrAlloc(10);

  StrCopy(p, '123456');
  ShowMessage(p); {123456}

  i := StrBufSize(p);
  ShowMessage(IntToStr(i)); {10}

  StrDispose(p);
end;

end.

 
 
 
 
 

 

 
  
SysUtils 单元下的公用函数目录

你可能感兴趣的:(SysUtils.StrAlloc、SysUtils.StrBufSize)