在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
相关资料: http://www.delphitop.com/html/zifuchuan/1242.html https://www.cnblogs.com/xumenger/p/4443955.html
【strlen】PChar 串专用函数:串长度
unit Unit1; interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls; type TForm1 = class(TForm) Button1: TButton; Button2: TButton; Button3: TButton; Button4: TButton; Button5: TButton; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure Button3Click(Sender: TObject); procedure Button4Click(Sender: TObject); procedure Button5Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); var s: Widestring; begin s := '桂枝香在故国晚秋'; ShowMessage(IntToStr(Length(String(s))));//XE显示8 //D7 结果不是8而是16 end; procedure TForm1.Button2Click(Sender: TObject); var s: Widestring; begin s := '桂枝香在故国晚秋'; ShowMessage(IntToStr(Length(s))); //XE显示8 //D7结果不是16而是8 end; procedure TForm1.Button3Click(Sender: TObject); var s: AnsiString; begin s:='桂枝香在故国晚秋'; ShowMessage(IntToStr(Length(s))); //XE显示16 end; procedure TForm1.Button4Click(Sender: TObject); var s: AnsiString; begin s:='桂枝香在故国晚秋'; ShowMessage(IntToStr(strlen(PWideChar(s)))); //XE显示8 end; procedure TForm1.Button5Click(Sender: TObject); var s: AnsiString; begin s:='桂枝香在故国晚秋'; ShowMessage(IntToStr(SizeOf(PWideChar(s)))); //XE显示4(32位程序) end; end.
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论