随笔 - 2146  文章 - 19 评论 - 11846 阅读 - 1267万

随笔分类 -  System 单元

1 2 下一页
System.SysUtils.TMarshaller 与 System.TMarshal
摘要:TMarshaller(结构) 基于 TMarshal(是有一大堆的 class 方法组成的类) 实现.TMarshaller 可以对缓存区进行自动(自动释放)安全地管理, TMarshal 也有前者没有的重要方法, 譬如: TMarshal.Copy() 方法.有了它们, 以后关于内存缓冲区, 字符串转码等操作就更方便了.{测试}procedure TForm1.FormCreate(Sender: TObject);var M: TMarshaller; pw: TPtrWrapper; str: string; bs: TBytes;begin bs := BytesOf('万. 阅读全文
posted @ 2013-06-10 18:27 万一 阅读(2470) 评论(0) 推荐(0) 编辑
System.TPtrWrapper - 指针包装器
摘要:不知什么时候 System 单元有了 TPtrWrapper 结构体, 它提供了非常小的一点功能: 指针(Pointer)与指针地址(NativeInt)的转换.很显然, 以前常用的 Integer(P) 或 Ptr(Number) 已经不适用与 64 位了, 这时使用 TPtrWrapper 应该是更方便,更保险的选择.发现在 Delphi 新的源码中, 几乎就把 TPtrWrapper 当做指针来使用了.{TPtrWrapper 全功能测试}procedure TForm1.FormCreate(Sender: TObject);var num: Integer; p: Pointer.. 阅读全文
posted @ 2013-06-10 12:14 万一 阅读(1741) 评论(3) 推荐(0) 编辑
学用 ASP.Net 之 System.TimeSpan 结构
摘要:TimeSpan 表示一个时间间隔, 如:其默认的字符串格式:成员:构建对象:Parse():属性测试:Duration()、Negate():格式化输出: 阅读全文
posted @ 2011-01-04 14:13 万一 阅读(3149) 评论(0) 推荐(1) 编辑
X 的 Y 次方
摘要:var x,y,z: Real;begin x := 2; y := 3; { 使用 Math.Power } z := Math.Power(x, y); ShowMessage(FloatToStr(z)); //8 { 不想 uses Math, 就用 System.Exp、System.Ln } z := Exp(Ln(x) * y); ShowMessage(Float... 阅读全文
posted @ 2009-12-19 09:54 万一 阅读(5224) 评论(1) 推荐(0) 编辑
System.Assert 断言
摘要:可用 {$ASSERTIONS OFF/ON} 决定是否启用 Assert; 默认只用于 Debug 版本. 阅读全文
posted @ 2009-12-10 11:55 万一 阅读(4960) 评论(6) 推荐(0) 编辑
System-Function
摘要:System.AbsSystem.AcquireExceptionObjectSystem.AddModuleUnloadProcSystem.AddrSystem.AllocMemSystem.AnsiToUtf8System.AppendSystem.ArcTanSystem.AssertSystem.AssignedSystem.AssignFileSystem.AttemptToUseSh... 阅读全文
posted @ 2009-05-20 06:31 万一 编辑
ParamCount、ParamStr
摘要://获取程序参数 //可从 Project -> Options -> Debugger -> Parameters 中输入模拟参数, 多个参数可用空格隔开 procedure TForm1.FormCreate(Sender: TObject); var i: Integer; begin for i := 1 to ParamCount do begin ListBox... 阅读全文
posted @ 2009-03-11 20:38 万一 阅读(3576) 评论(2) 推荐(0) 编辑
带进度的文件复制 - 回复 "冷风无泪" 的问题
摘要:问题来源: http://www.cnblogs.com/del/archive/2008/12/02/1066817.html#1389078本例效果图:代码文件:unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtr... 阅读全文
posted @ 2008-12-02 22:18 万一 阅读(5372) 评论(13) 推荐(1) 编辑
学习官方示例 - System.RunError
摘要:unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Button1: TButton; procedure Button... 阅读全文
posted @ 2008-09-11 14:16 万一 阅读(5009) 评论(5) 推荐(0) 编辑
学习官方示例 - System.Frac: 返回小数部分
摘要:unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Button1: TButton; procedure Button... 阅读全文
posted @ 2008-09-11 14:09 万一 阅读(4720) 评论(2) 推荐(0) 编辑
使用 System.Sin、System.Cos 函数画圆 - 绘制五环图标
摘要:本例效果图: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Button1: TButton; procedur... 阅读全文
posted @ 2008-05-27 22:21 万一 阅读(7202) 评论(10) 推荐(0) 编辑
关于 Lo、Hi、LoWord、HiWord
摘要:Cardinal 是 4 字节无符号的整型, 先看一个例数: Cardinal 例数: 4277991664 按字节划分: 第四字节 第三字节 第二字节 第一字节 二进制: 11111110 11111100 11111000 11110000 十六进制: FE FC F8 F0 十进制: 254 252 248 240 按双字节划分: 高两位 低... 阅读全文
posted @ 2008-04-23 15:14 万一 阅读(11077) 评论(3) 推荐(0) 编辑
System.Odd - 判断一个整数是不是奇数
摘要:举例: var i: Integer; b: Boolean; begin i := 11; b := Odd(i); {是奇数返回真} ShowMessage(BoolToStr(b)); {True} i := 12; b := Odd(i); ShowMessage(BoolToStr(b)); {False} end; ... 阅读全文
posted @ 2008-03-30 23:13 万一 阅读(4296) 评论(2) 推荐(0) 编辑
System.Sqr、System.Sqrt - 平方与平方根
摘要:举例: var d: Real; begin d := Sqr(6); ShowMessage(FloatToStr(d)); {36} end; var d: Real; begin d := Sqrt(81); ShowMessage(FloatToStr(d)); {9} end; System 单元下的公用函数目录 阅读全文
posted @ 2008-03-30 23:12 万一 阅读(4801) 评论(0) 推荐(0) 编辑
System.Trunc、System.Round、System.Int - 返回整数部分
摘要:举例:var i: Integer; d: Real;begin i := Trunc(1234.5678); {截取整数} ShowMessage(IntToStr(i)); {1234} i := Trunc(-1234.5678); ShowMessage(IntTo... 阅读全文
posted @ 2008-03-30 23:09 万一 阅读(3144) 评论(2) 推荐(0) 编辑
System.Abs - 绝对值
摘要:举例: var d: Real; v: Variant; begin d := Abs(-1.2); ShowMessage(FloatToStr(d)); {1.2} v := '-100'; ShowMessage(v); {-100; v 是变体类型可以直接显示} v := Abs(v); ShowMessage(v); ... 阅读全文
posted @ 2008-03-30 22:55 万一 阅读(3723) 评论(0) 推荐(0) 编辑
System.SetString - 获取字符串
摘要:举例: var ss,s: string; begin ss := 'CodeGear Delphi 2007'; SetString(s,PChar(ss),4); ShowMessage(s); {Code} end; var s: string; arr: array[0..6] of Char; i: Integer; begin for i := 0... 阅读全文
posted @ 2008-03-29 22:58 万一 阅读(7117) 评论(3) 推荐(0) 编辑
System.Val - 将字符串转换为数字
摘要:举例: var s: string; i: Real; j: Integer; begin s := '13.2435'; Val(s,i,j); ShowMessage(FloatToStr(i)); {13.2435} ShowMessage(IntToStr(j)); {返回 0 表示转换成功} s := '13_2435'; Val(s,i,... 阅读全文
posted @ 2008-03-29 22:50 万一 阅读(5292) 评论(0) 推荐(0) 编辑
System.Str - 将数字格式化为字符串
摘要:举例: var s: string; begin Str(123, s); ShowMessage(s); {123} Str(PI, s); ShowMessage(s); {3.14159265358979E+0000} Str(PI:0:2, s); ShowMessage(s); {3.14} Str(9.1:1:3, s); ShowMe... 阅读全文
posted @ 2008-03-29 22:43 万一 阅读(2959) 评论(0) 推荐(1) 编辑
System.FillChar - 填充字节
摘要:举例: var s: array[0..9] of Char; begin FillChar(s,SizeOf(s),'a'); ShowMessage(s); {aaaaaaaaaa} end; var arr: array[0..3] of Word; i: Integer; begin FillChar(arr, Length(arr) * SizeOf(Wor... 阅读全文
posted @ 2008-03-29 22:36 万一 阅读(5431) 评论(2) 推荐(1) 编辑

1 2 下一页


点击右上角即可分享
微信分享提示