Delphi函数大全.docx
《Delphi函数大全.docx》由会员分享,可在线阅读,更多相关《Delphi函数大全.docx(21页珍藏版)》请在冰豆网上搜索。
![Delphi函数大全.docx](https://file1.bdocx.com/fileroot1/2023-6/22/1972e689-52c5-43e5-8c4e-5b074bd9c937/1972e689-52c5-43e5-8c4e-5b074bd9c9371.gif)
Delphi函数大全
Delphi函数大全
首部functionLanguages:
TLanguages;$[
功能返回系统语言对象
说明通过此函数可以得到系统的语言环境
参考type
例子
12a12c12a12c.
参考
例子:
=IsValidIdent;
━━━━━━━━━━━━━━━━━━━━━
首部functionIntToStr(Value:
Integer):
string;overload;$[
首部functionIntToStr(Value:
Int64):
string;overload;$[
功能返回整数Value转换成字符串
说明Format('%d',[Value])
参考function
例子:
=IntToStr;
━━━━━━━━━━━━━━━━━━━━━
首部functionIntToHex(Value:
Integer;Digits:
Integer):
string;overload;$[
首部functionIntToHex(Value:
Int64;Digits:
Integer):
string;overload;$[
功能返回整数Value转换成十六进制表现结果;Format('%.*x',[Digits,Value])
说明参数Digits指定字符最小宽度;最小宽度不足时将用0填充
参考function
例子:
=IntToHex,;
━━━━━━━━━━━━━━━━━━━━━
首部functionStrToInt(constS:
string):
Integer;$[
功能返回字符串S转换成整数
说明字符串非整数表达时将引起异常
参考procedure
例子:
=StrToInt;
━━━━━━━━━━━━━━━━━━━━━
首部functionStrToIntDef(constS:
string;Default:
Integer):
Integer;$[
功能返回字符串S转换成整数
说明字符串非整数表达时则返回默认值Default
参考procedure
例子:
=StrToIntDef,0);
━━━━━━━━━━━━━━━━━━━━━
首部functionTryStrToInt(constS:
string;outValue:
Integer):
Boolean;$[
功能返回字符串S转换成整数Value是否成功
说明字符串非整数表达时返回False并且Value将输出为0
参考procedure
例子
..);打开失败则返回负数
参考function
例子
xe'
参考function;function
例子:
=ExtractFileExt;
━━━━━━━━━━━━━━━━━━━━━
首部functionExpandFileName(constFileName:
string):
string;$[
功能返回文件名的完整表示
说明ExpandFileName('')='C:
\ProgramFiles\Borland\Delphi6\Projects\'
参考function
例子:
=ExpandFileName;
━━━━━━━━━━━━━━━━━━━━━
首部functionExpandFileNameCase(constFileName:
string;outMatchFound:
TFilenameCaseMatch):
string;$[
功能分情况返回文件名的完整表示
说明typeTFilenameCaseMatch=(mkNone,mkExactMatch,mkSingleMatch,mkAmbiguous);
参考function;function;function
例子
.;获取失败则返回-1
参考function
例子:
=DiskFree;
━━━━━━━━━━━━━━━━━━━━━
首部functionDiskSize(Drive:
Byte):
Int64;$[
功能返回驱动器全部空间
说明参数Drive为0表示当前路径,为1表示=A驱,为2表示=B驱...;获取失败则返回-1
参考function
例子:
=DiskSize;
━━━━━━━━━━━━━━━━━━━━━
首部functionFileDateToDateTime(FileDate:
Integer):
TDateTime;$[
功能返回将文件日期时间类型转换日期时间类型
说明FileDate非法是将触发异常
参考function;function
例子<参见FileAge>
━━━━━━━━━━━━━━━━━━━━━
首部functionDateTimeToFileDate(DateTime:
TDateTime):
Integer;$[
功能返回将日期时间类型转换文件日期时间类型
说明年份在1980到2107之外则返回0
参考function;function
例子<参见FileSetDate>
━━━━━━━━━━━━━━━━━━━━━
首部functionGetCurrentDir:
string;$[
功能返回当前操作目录
说明[注意]调用文件对话框会改变当前操作目录
参考function
例子:
=GetCurrentDir;
━━━━━━━━━━━━━━━━━━━━━
首部functionSetCurrentDir(constDir:
string):
Boolean;$[
功能返回设置当前操作目录是否成功
说明[注意]调用文件对话框会改变当前操作目录
参考function
例子:
=SetCurrentDir;
━━━━━━━━━━━━━━━━━━━━━
首部functionCreateDir(constDir:
string):
Boolean;$[
功能返回创建目录是否成功
说明不支持多级目录;已经存在则返回False
参考function
例子:
=CreateDir;
━━━━━━━━━━━━━━━━━━━━━
首部functionRemoveDir(constDir:
string):
Boolean;$[
功能返回删除目录是否成功
说明必须是空目录
参考function
例子:
=RemoveDir;
━━━━━━━━━━━━━━━━━━━━━
首部functionStrLen(constStr:
PChar):
Cardinal;$[
功能返回指针字符串的长度
说明当指针字符串Str为nil时将触发异常
参考
例子:
=StrLen(PChar);
━━━━━━━━━━━━━━━━━━━━━
首部functionStrEnd(constStr:
PChar):
PChar;$[
功能返回指针字符串的结尾
说明当指针字符串Str为nil时将触发异常
参考
例子:
=StrEnd(PChar)-;
━━━━━━━━━━━━━━━━━━━━━
首部functionStrMove(Dest:
PChar;constSource:
PChar;Count:
Cardinal):
PChar;$[
功能返回将指针字符串Source指定内存数量Count复制覆盖到指针字符串Dest中
说明Dest没有分配资源将触发异常s
参考function
例子
255]ofChar;
begin
StrECopy(StrECopy(vBuffer,PChar),PChar);
:
=vBuffer;
end;
255]ofChar;
begin
StrLCopy(vBuffer,PChar,;
:
=vBuffer;
end;
255]ofChar;
begin
StrPCopy(vBuffer,PChar);
:
=vBuffer;
end;
255]ofChar;
begin
StrPLCopy(vBuffer,,;
:
=vBuffer;
end;
255]ofChar;
begin
StrPCopy(vBuffer,;
StrCat(vBuffer,PChar);
:
=vBuffer;
end;
255]ofChar;
begin
StrPCopy(vBuffer,;
StrLCat(vBuffer,PChar,;
:
=vBuffer;
end;
2005-7-26摘要]类型
Format('x=%d',[12]);3f,[]);f',[5,]);d',[12]);x',[12]);0000C255]ofChar;
E:
Extended;
begin
E:
=StrToFloatDef,0);
:
=FloatToText(vBuffer,E,
fvExtended,ffNumber,,;
:
=Copy(vBuffer,1,;
end;
0',90)='1,234,567,'
参考function
例子:
=FormatFloat,StrToFloatDef,0));
━━━━━━━━━━━━━━━━━━━━━
首部functionFormatCurr(constFormat:
string;Value:
Currency):
string;$[
功能返回货币类型以指定格式字符串Format转换成字符串
说明FormatCurr(',.00',90)='1,234,567,'
参考function
例子:
=FormatCurr,StrToCurrDef,0));
━━━━━━━━━━━━━━━━━━━━━
首部functionFloatToTextFmt(Buf:
PChar;constValue;ValueType:
TFloatValue;Format:
PChar):
Integer;$[
功能返回浮点数以指定格式字符串Format转换成指针字符串的内存大小
说明ValueType指定无类型参数Value的类型
参考
例子
255]ofChar;
E:
Extended;
begin
E:
=StrToFloatDef,0);
:
=FloatToTextFmt(vBuffer,E,
fvExtended,PChar);
:
=Copy(vBuffer,1,;
end;
7]ofstring=
('星期天','星期一','星期二','星期三','星期四','星期五','星期六');
begin
:
=cWeekCn[DayOfWeek(Now)];
end;
2002-03-092002年03月09日255]ofChar;
begin
ExceptionErrorMessage(Self,Self,vBuffer,255);
Caption:
=vBuffer;
end;
'')=16
参考function;function
例子:
=LastDelimiter,;
━━━━━━━━━━━━━━━━━━━━━
首部functionAnsiCompareFileName(constS1,S2:
string):
Integer;$[
功能返回比较两个文件名
说明当S1>S2返回值>0;当S1参考function
例子:
=AnsiCompareFileName,;
━━━━━━━━━━━━━━━━━━━━━
首部functionSameFileName(constS1,S2:
string):
Boolean;$[
功能返回两个文件名是否相等
说明区分大小写
参考function
例子:
=SameFileName,;
━━━━━━━━━━━━━━━━━━━━━
首部functionAnsiLowerCaseFileName(constS:
string):
string;$[
功能返回小写文件名
说明在非多字节字符系统上相当于AnsiLowerCase
参考function
例子:
=AnsiLowerCaseFileName;
━━━━━━━━━━━━━━━━━━━━━
首部functionAnsiUpperCaseFileName(constS:
string):
string;$[
功能返回大写文件名
说明在非多字节字符系统上相当于AnsiUpperCase
参考function
例子:
=AnsiUpperCaseFileName;
━━━━━━━━━━━━━━━━━━━━━
首部functionAnsiPos(constSubstr,S:
string):
Integer;$[
功能返回子串Substr在字符中第一次出现的位置
说明不存在则返回0
参考
例子:
=AnsiPos,;
━━━━━━━━━━━━━━━━━━━━━
首部functionAnsiStrPos(Str,SubStr:
PChar):
PChar;$[
功能返回指针子串Substr在指针字符中第一次出现的指针位置
说明不存在则返回nil
参考function
例子:
=AnsiStrPos(PChar,PChar);
━━━━━━━━━━━━━━━━━━━━━
首部functionAnsiStrRScan(Str:
PChar;Chr:
Char):
PChar;$[
功能返回在指针字符串Str搜索字符Chr最后一个出现的地址
说明支持多字节字符系统;AnsiStrRScan('','.')=''
参考function
例子:
=AnsiStrScan(PChar,'.');
━━━━━━━━━━━━━━━━━━━━━
首部functionAnsiStrScan(Str:
PChar;Chr:
Char):
PChar;$[
功能返回在指针字符串Str搜索字符Chr第一个出现的地址
说明支持多字节字符系统;AnsiStrRScan('','.')='.'
参考function
例子:
=AnsiStrScan(PChar,'.');
━━━━━━━━━━━━━━━━━━━━━
首部functionStringReplace(constS,OldPattern,NewPattern:
string;Flags:
TReplaceFlags):
string;$[
功能返回替换后的字符串
说明rfReplaceAll为替换全部内容;rfIgnoreCase为忽略大小写
参考function;function;function
例子
///////BeginStringReplace
procedure(Sender:
TObject);
begin
'[]']:
=
StringReplace,,,[]);
'[rfReplaceAll]']:
=
StringReplace,,,[rfReplaceAll]);
'[rfIgnoreCase]']:
=
StringReplace,,,[rfIgnoreCase]);
'[rfReplaceAll,rfIgnoreCase]']:
=
StringReplace,,,[rfReplaceAll,rfIgnoreCase]);
end;
///////EndStringReplace
━━━━━━━━━━━━━━━━━━━━━
首部functionWrapText(constLine,BreakStr:
string;constBreakChars:
TSysCharSet;MaxCol:
Integer):
string;overload;$[
首部functionWrapText(constLine:
string;MaxCol:
Integer=45):
string;overload;$[
功能返回对字符串自动换行
说明Result:
=WrapText(Line,sLineBreak,['','-',#9],MaxCol);
参考function;function
例子:
=WrapText,;
━━━━━━━━━━━━━━━━━━━━━
首部functionFindCmdLineSwitch(constSwitch:
string;constChars:
TSysCharSet;IgnoreCase:
Boolean):
Boolean;overload;$[
首部functionFindCmdLineSwitch(constSwitch:
string):
Boolean;overload;$[
首部functionFindCmdLineSwitch(constSwitch:
string;IgnoreCase:
Boolean):
Boolean;overload;$[
功能返回程序命令参数是否找到
说明Result:
=FindCmdLineSwitch(Switch,SwitchChars,True);
参考function;function;function
例子:
=FindCmdLineSwitch;
━━━━━━━━━━━━━━━━━━━━━
首部procedureFreeAndNil(varObj);$[
功能释放对象Obj并赋为空
说明如果对象已经释放资源将触发异常
参考type
例子
///////BeginFreeAndNil
procedure(Sender:
TObject);
var
Temp:
TObject;
begin
Temp:
=;
;
ShowMessage(Format('%p',[Pointer(Temp)]));
Temp:
=;
FreeAndNil(Temp);
ShowMessage(Format('%p',[Pointer(Temp)]));
end;
///////EndFreeAndNil
━━━━━━━━━━━━━━━━━━━━━
首部functionSupports(constInstance:
IInterface;constIID:
TGUID;outIntf):
Boolean;overload;$[
首部functionSupports(constInstance:
TObject;constIID:
TGUID;outIntf):
Boolean;overload;$[
首部functionSupports(constInstance:
IInterface;constIID:
TGUID):
Boolean;overload;$[
首部functionSupports(constInstance:
TObject;constIID:
TGUID):
Boolean;overload;$[
首部functionSupports(constAClass:
TClass;constIID:
TGUID):
Boolean;overload;$[
功能返回对象是否支持指定的接口
说明Result:
=(IID)<>nil;
参考type
例子
━━━━━━━━━━━━━━━━━━━━━
首部functionCreateGUID(outGuid:
TGUID):
HResult;$[
功能返回创建全局标识是否成功
说明返回S_OK表示成功
参考function
例子
///////BeginCreateGUID
procedure(Sender:
TObject);
var
vGUID:
TGUID;
begin
CreateGUID(vGUID);
:
=GUIDToString(vGUID);
end;
///////EndCreateGUID
━━━━━━━━━━━━━━━━━━━━━
首部functionStringToGUID(constS:
string):
TGUID;$[
功能返回字符串S转换成全局标识
说明如果字符串非法将触发异常
参考fuction
例子:
=GUIDToString(StringToGUID);
━━━━━━━━━━━━━━━━━━━━━
首部functionGUIDToString(constGUID:
TGUID):
string;$[
功能返回全局标识GUID转换成字符串
说明
参考fuction
例子:
=GUIDToString(StringToGUID);
━━━━━━━━━━━━━━━━━━━━━
首部functionIsEqualGUID(constguid1,guid2:
TGUID):
Boolean;$[
功能返回两个全局标识是否相同
说明functionIsEqualGUID;external''name'IsEqualGUID';
参考
例子:
=IsEqualGUID(StringToGUID,StringToGUID);
━━━━━━━━━━━━━━━━━━━━━
首部functionLoadPackage(constName:
string):
HMODULE;$[
功能返回载入包资源
说明
参考function;function;function
例子
━━━━━━━━━━━━━━━━━━━━━
首部procedureUnloadPackage(Module:
HMODULE);$[
功能取消载入包资源
说明
参考function;function
例子
━━━━━━━━━━━━━━━━━━━━━
首部procedureGetPackageInfo(Module:
HMODULE;Param:
Pointer;varFlags:
Integer;InfoProc:
TPackageInfoProc);$[
功能返回包的信息
说明