打印本文 打印本文 关闭窗口 关闭窗口
DELPHI常用函数集及简要范例
作者:武汉SEO闵涛  文章来源:敏韬网  点击数19885  更新时间:2009/4/23 18:30:33  文章录入:mintao  责任编辑:mintao
sp;   procedure AssignCrt(var f: Text);
ClrEol     清附游标位置到该行最後的所有字元。procedure ClrEol;
ClrScr     清附萤幕并重置游标至左上角。      procedure ClrScr;
CursorTo   移动游标至给定座标。              procedure CursorTo(X, Y:Integer);
DoneWinCrt 结束控制台视窗。                  procedure DoneWinCrt;
GotoXY     移动游标至给定座标。              procedure GotoXY(X, Y: Byte);
InitWinCrt 建立控制台视窗。                  procedure InitWinCrt;
KeyPressed 判断是否有一按键。                function KeyPressed:Boolean;
ReadBuf    从控制台视窗读入一行。            function ReadBuf(Buffer: Pchar;Count: Word):
ReadKey 读取按键字元。function ReadKey: Char;
ScrollTo 卷动控制台视窗至显示位置。procedure ScrollTo(X, Y: Integer);
TrackCursor 卷动控制台视窗宜到游标可见。procedure TrackCursor;
WhereX 传回游标的X 座标。function WhereX: Byte;
WhereY 传回游标的Y 标标。function WhereY: Byte;
WriteBuf 写入一区块字元到控制台视窗。procedure WriteBuf
WriteChar 写一个字元到控制台视窗。procedure WriteChar(CH: Char);
=================================================
日期与时间函数 (Date and Time Routines)
Unit: SysUtils
========================================
Date 传回今天日期。function Date: TDateTime;
DateTimeToStr 将时间格式转为字串。function DateTimeToStr(DateTime: TDateTime):String;
DateTimeToString 将时间格式转为字串。
procedure DateTimeToString(var Result: string;const Format: string;DateTime: TDateTime);
DateToStr 将日期格式转为字串。function DateToStr(Date: TDateTime): String;
DayOfWeek 传回今天星期几。function DayOfWeek(Date: TDateTime): Integer;
DecodeDate 分解所指定的日期为年、月、日。
procedure DecodeDate(Date: TDateTime;var Year, Month, Day:Word);
DecodeTime 分解所指定的日期为时、分、秒。
procedure DecodeTime(Time: TDateTime;var Hour, Min, Sec,MSec: Word);
EncodeDate 传回将年、月、日所组合的日期格式。
function EncodeDate(Year, Month, Day: Word):TDateTime;
EncodeTime 传回将时、分、秒所组合的时间格式。
function EncodeTime(Hour, Min, Sec, MSec:Word): TDateTime;
FormatDateTime 以指定的格式传回日期时间。
function FormatDateTime(const Format: string;DateTime: TDateTime):String;
Now 传回现在的日期时间。function Now: TDateTime;
StrToDate 将字串转为日期格式。function StrToDate(const S:string): TDateTime;
StrToDateTime 将字串转为日期时间格式function StrToDateTime(const S: string): TDateTime;
StrToTime 将字串转为时间格式。function StrToTime(const S:string): TDateTime;
Time 传回现在时间。function Time: TDateTime;
TimeToStr 将时格式转为字串。function TimeToStr(Time:TDateTime): String;
========================================
动态配置函数(Dynamic Allocation Routines)
Unit: System
========================================
Dispose 释回一个动态变数。procedure Dispose(var P: Pointer);
Free 释放一个物件复本。procedure Free;
FreeMem 释回一给定大小的动态变数。procedure FreeMem(var P:Pointer; Size: Word);
GetMem 建立一个指定大小的动态变数,并由Pointer 叁数传回位址。
procedure GetMem(var P:Pointer; Size: Word);
New 建立一个新的动态变数,并将Pointer 叁数指向它。
procedure New(var P: Pointer);
function New(<pointer type>):Pointer;
MaxAvail 传回连续最大的可配置空间。function MaxAvail: Longint;
MemAvail 传回所有的可配置空间。function MemAvail: Longint;
========================================
档案管理函数
Unit: SysUtils
========================================
ChangeFileExt 变更档案的延伸档名。
function ChangeFileExt(const FileName,Extension: string):string;
DateTimeToFileDate 将Delphi 的日期格式转换为DOS的日期格式。
functionDateTimeToFileDate(DateTime:TDateTime): Longint;
DeleteFile 删除一个档案。
function DeleteFile(const FileName: string):Boolean;
DiskFree 传回磁碟的可用空间。function DiskFree(Drive: Byte): Longint;
DiskSize 传回指定磁碟的容量大小。function DiskSize(Drive: Byte): Longint;
ExpandFileName 传回一个完整的路径及档名字串。
function expandFileName(const FileName: string):string;
ExtractFileExt 传回档案的延伸档名。function ExtractFileExt(const FileName string):string;
ExtractFileName 传回档案的档名。function ExtractFileName(const FileName: string):string;
ExtractFilePath 传回档案的路径。function ExtractFilePath(const FileName: string):string;
FileAge 传回档案的年纪function FileAge(const FileName: string):Longint;
FileCreate 以指定档名建立一个档案。function FileCreate(const FileName: string):Integer;
FileClose 关闭指定的档案。procedureFileClose(Handle: Integer);
FileDateToDateTime 将DOS 的日期格式转为Delphi 的日期格式。
function FileDateToDateTime(FileDate: Longint):TDateTime;
FileExists 判别档案是否存在。function FileExists(const FileName: string):Boolean;
FileGetAttr 传回档案属性。function FileGetAttr(const FileName: string):Integer;
FileGetDate 传回档案的日期及时间。function FileGetDate(Handle: Integer): Longint;
FileRead 从指定的档案读入资料。
function FileRead(Handle:Integer; var Buffer;Count:Longint):Longint;
FileSearch 在目录列中搜寻指定的档案。function FileSearch(constName, DirList: string):string;
FileSeek 改变档案游标的位置。function FileSeek(Handle: Integer;Offset: Longint;Origin: Integer):Longint;
FileSetAttr 设定档案属性。function FileSetAttr(const FileName: string;Attr:Integer): Integer;
FileSetDate 设定档案的日期及时间。procedure FileSetDate(Handle: Integer; Age:Longint);
FileOpen 开启档案。function FileOpen(const FileName: string; Mode:Word): Integer;
FileWrite 写资料到档案。function FileWrite(Handle:Integer;const Buffer; Count:Longint): Longint;
FindClose 终止找寻第一个/下一个的动作。procedure FindClose(var SearchRec: TSearchRec);
FindFirst 寻找第一个符合的档案并设定其属性。
function FindFirst(const Path: string;Attr: Word; var F:TSearchRec): Integer;
FindNext 传回下一个符合的档案。function FindNext(var F:TSearchRec): Integer;
RenameFile 变更档名。function RenameFile(const OldName,NewName: string):Boolean;
========================================
浮点数转换函数 (Floating-point Conversion Routines)
Unit: SysUtils
========================================
FloatToDecimal 将浮点数值分成小数及整数部份的数字传回。
procedure FloatToDecimal(var Result: TFloatRec;Value:Extended;Precision, Decimals:Integer);
FloatToStrF 依照指定格式将浮点数转成字串描述。
function FloatToStrF(Value: Extended; Format:TFloatFormat;Precision,Digits: Integer): string;
FloatToStr 将浮点数转成字串描述。function FloatToStr(Value: Extended): string;
FloatToText 将所给的浮点数值,分成小数及整数部份的数字依照格式传回。
function FloatToText(Buffer: Pchar; Value:Extended;Format:TFloatFormat;Precision,Digits: Integer): Integer;
FloatToTextFmt 将浮点数依照格式转成字串传回。
function FloatToTextFmt(Buffer: PChar; Value:Extended;Format: PChar) :Integer;
FormatFloat 将浮点数值依照Format 格式传回。
function FormatFloat(constFormat: string;Value:Extended):string;
StrToFloat 将所给字串转成一个浮点数值。
function StrToFloat(const S: string): Extended;
TextToFloat 将一个null 结尾字串转成浮点数值
function TextToFloat(Buffer: PChar;var Value:Extended): Boolean;
========================================
流程控制函数 (Flow-control Routines)
Unit: System
========================================
Break 终止回圈。如for, while 及repeat 回圈。
procedure Break;
Continue 继续回圈。如for, while 及repeat 回圈。
procedure Continue;
Exit 离开目前的区块。procedure Exit;
Halt 停止程式的执行并回到作业系统。
procedure Halt[ ( Exitcode: Word ) ];
RunError 停止程式执行。procedure RunError[ ( Errorcode: Byte ) ];
========================================
输出入函数 (I/O Routines)
Unit: System
========================================
AssignFile 指定一个档案到档案变数。procedure AssignFile(var f, String);
CloseFile 关闭档案。procedure CloseFile(var F);
Eof 判断是否已到档案结尾。
Typed or untyped files: functionEof(var F): BooleanText files:function Eof [ (var F: Text) ]:Boolean;
Erase 清除档案内容。procedure Erase(var F);
FilePos 传回目前档案游标位置。function FilePos(var F): Longint;
FileSize 传回档案的大小function FileSize(var F):Longint;
GetDir 传回指定磁碟的工作目录。procedure GetDir(D: Byte; var S: String);
IOResult 传回最後I/O 执行的状态。function IOResult: Integer;
MkDir 建立一子目录。procedure MkDir(S: String);
Rename 变更外部档案的档名。procedure R

 << 上一页  [21] [22] [23] [24] [25] [26] [27] [28] [29] [30]  ...  下一页 >> 

打印本文 打印本文 关闭窗口 关闭窗口