unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
p,p1: PChar;
begin
p1 := 'Delphi';
GetMem(p, 256);
lstrcpy(p, p1);
ShowMessage(p); {Delphi}
FreeMem(p);
end;
procedure TForm1.Button2Click(Sender: TObject);
var
p,p1,p2: PChar;
begin
p1 := 'Delphi';
p2 := '2009';
p := StrAlloc(256);
lstrcpy(p, p1);
lstrcpy(p, p2);
ShowMessage(p); {2009}
StrDispose(p);
end;
procedure TForm1.Button3Click(Sender: TObject);
var
p: PChar;
buf: array[0..255] of Char;
begin
p := '万一的 Delphi 博客';
lstrcpy(buf, p);
ShowMessage(buf); {万一的 Delphi 博客}
end;
end.
WinAPI 字符及字符串函数(10): lstrcpy - 复制字符串
原创
©著作权归作者所有:来自51CTO博客作者JLee79的原创作品,请联系作者获取转载授权,否则将追究法律责任
posted on 2008-11-05 21:18 万一 阅读(3874) 评论(4) 编辑 收藏

提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
字符函数和字符串函数
与字符串相关的函数
赋值 无符号整数 字符串