登录 注册
当前位置:主页 > 资源下载 > 9 > Delphi提供的文件目录操作扩展函数

Delphi提供的文件目录操作扩展函数

  • 更新:2024-08-10 11:36:32
  • 大小:33KB
  • 推荐:★★★★★
  • 来源:网友上传分享
  • 类别:Access - 数据库
  • 格式:TXT

资源介绍

function MoveFile(const sName, dName: string): Boolean; {* 移动文件、目录,参数为源、目标名} procedure FileProperties(const FName: string); {* 打开文件属性窗口} function OpenDialog(var FileName: string; Title: string; Filter: string; Ext: string): Boolean; {* 打开文件框} function FormatPath(APath: string; Width: Integer): string; {* 缩短显示不下的长路径名} function GetRelativePath(Source, Dest: string): string; {* 取两个目录的相对路径,注意串尾不能是'\'字符!} procedure RunFile(const FName: string; Handle: THandle = 0; const Param: string = ''); {* 运行一个文件} function WinExecAndWait32(FileName: string; Visibility: Integer = SW_NORMAL): Integer; {* 运行一个文件并等待其结束} function AppPath: string; {* 应用程序路径} function GetWindowsDir: string; {* 取Windows系统目录} function GetWinTempDir: string; {* 取临时文件目录} function AddDirSuffix(Dir: string): string; {* 目录尾加'\'修正} function MakePath(Dir: string): string; {* 目录尾加'\'修正} function IsFileInUse(FName: string): Boolean; {* 判断文件是否正在使用} function GetFileSize(FileName: string): Integer; {* 取文件长度} function SetFileDate(FileName: string; CreationTime, LastWriteTime, LastAccessTime: TFileTime): Boolean; {* 设置文件时间} function GetFileDate(FileName: string; var CreationTime, LastWriteTime, LastAccessTime: TFileTime): Boolean; {* 取文件时间} function FileTimeToLocalSystemTime(FTime: TFileTime): TSystemTime; {* 文件时间转本地时间} function LocalSystemTimeToFileTime(STime: TSystemTime): TFileTime; {* 本地时间转文件时间} function GetFileIcon(FileName: string; var Icon: TIcon): Boolean; {* 取得与文件相关的图标,成功则返回True} function CreateBakFile(FileName, Ext: string): Boolean; {* 创建备份文件} function Deltree(Dir: string): Boolean; {* 删除整个目录} function GetDirFiles(Dir: string): Integer; {* 取文件夹文件数} type TFindCallBack = procedure(const FileName: string; const Info: TSearchRec; var Abort: Boolean); {* 查找指定目录下文件的回调函数} procedure FindFile(const Path: string; const FileName: string = '*.*'; Proc: TFindCallBack = nil; bSub: Boolean = True; const bMsg: Boolean = True); {* 查找指定目录下文件} function OpenWith(const FileName: string): Integer; {* 文件打开方式} //----------------------------------------------------------------------------// //扩展的字符串操作函数 // //----------------------------------------------------------------------------// function InStr(const sShort: string; const sLong: string): Boolean; {* 判断s1是否包含在s2中} function IntToStrEx(Value: Integer; Len: Integer; FillChar: Char = '0'): string; {* 扩展整数转字符串函数} function IntToStrSp(Value: Integer; SpLen: Integer = 3; Sp: Char = ','): string; {* 带分隔符的整数-字符转换} function ByteToBin(Value: Byte): string; {* 字节转二进制串} function StrRight(Str: string; Len: Integer): string; {* 返回字符串右边的字符} function StrLeft(Str: string; Len: Integer): string; {* 返回字符串左边的字符} function Spc(Len: Integer): string; {* 返回空格串} procedure SwapStr(var s1, s2: string); {* 交换字串} function LinesToStr(const Lines: string): string; {* 多行文本转单行(换行符转'\n')} function StrToLines(const Str: string): string; {* 单行文本转多行('\n'转换行符)} //----------------------------------------------------------------------------// //扩展的对话框函数 // //----------------------------------------------------------------------------// procedure InfoDlg(Mess: string; Caption: string = SCnInformation; Flags: Integer = MB_OK + MB_ICONINFORMATION); {* 显示提示窗口} function InfoOk(Mess: string; Caption: string = SCnInformation): Boolean; {* 显示提示确认窗口} procedure ErrorDlg(Mess: string; Caption: string = SCnError); {* 显示错误窗口} procedure WarningDlg(Mess: string; Caption: string = SCnWarning); {* 显示警告窗口} function QueryDlg(Mess: string; Caption: string = SCnInformation): Boolean; {* 显示查询是否窗口} //----------------------------------------------------------------------------// //扩展日期时间操作函数 // //----------------------------------------------------------------------------// function GetYear(Date: TDate): Integer; {* 取日期年份分量} function GetMonth(Date: TDate): Integer; {* 取日期月份分量} function GetDay(Date: TDate): Integer; {* 取日期天数分量} function GetHour(Time: TTime): Integer; {* 取时间小时分量} function GetMinute(Time: TTime): Integer; {* 取时间分钟分量} function GetSecond(Time: TTime): Integer; {* 取时间秒分量} function GetMSecond(Time: TTime): Integer; {* 取时间毫秒分量} //----------------------------------------------------------------------------// //位操作函数 // //----------------------------------------------------------------------------// type TByteBit = 0..7; {* Byte类型位数范围} TWordBit = 0..15; {* Word类型位数范围} TDWordBit = 0..31; {* DWord类型位数范围} procedure SetBit(var Value: Byte; Bit: TByteBit; IsSet: Boolean); overload; {* 设置二进制位} procedure SetBit(var Value: WORD; Bit: TWordBit; IsSet: Boolean); overload; {* 设置二进制位} procedure SetBit(var Value: DWORD; Bit: TDWordBit; IsSet: Boolean); overload; {* 设置二进制位} function GetBit(Value: Byte; Bit: TByteBit): Boolean; overload; {* 取二进制位} function GetBit(Value: WORD; Bit: TWordBit): Boolean; overload; {* 取二进制位} function GetBit(Value: DWORD; Bit: TDWordBit): Boolean; overload; {* 取二进制位} //----------------------------------------------------------------------------// //系统功能函数 // //----------------------------------------------------------------------------// procedure MoveMouseIntoControl(AWinControl: TControl); {* 移动鼠标到控件} function DynamicResolution(x, y: WORD): Boolean; {* 动态设置分辨率} procedure StayOnTop(Handle: HWND; OnTop: Boolean); {* 窗口最上方显示} procedure SetHidden(Hide: Boolean); {* 设置程序是否出现在任务栏} procedure SetTaskBarVisible(Visible: Boolean); {* 设置任务栏是否可见} procedure SetDesktopVisible(Visible: Boolean); {* 设置桌面是否可见} procedure BeginWait; {* 显示等待光标} procedure EndWait; {* 结束等待光标} function CheckWindows9598: Boolean; {* 检测是否Win95/98平台} //----------------------------------------------------------------------------// //其它过程 // //----------------------------------------------------------------------------// function TrimInt(Value, Min, Max: Integer): Integer; overload; {* 输出限制在Min..Max之间} function IntToByte(Value: Integer): Byte; overload; {* 输出限制在0..255之间} function InBound(Value: Integer; Min, Max: Integer): Boolean; {* 判断整数Value是否在Min和Max之间} procedure CnSwap(var A, B: Byte); overload; {* 交换两个数} procedure CnSwap(var A, B: Integer); overload; {* 交换两个数} procedure CnSwap(var A, B: Single); overload; {* 交换两个数} procedure CnSwap(var A, B: Double); overload; {* 交换两个数} function RectEqu(Rect1, Rect2: TRect): Boolean; {* 比较两个Rect是否相等} procedure DeRect(Rect: TRect; var x, y, Width, Height: Integer); {* 分解一个TRect为左上角坐标x, y和宽度Width、高度Height} function EnSize(cx, cy: Integer): TSize; {* 返回一个TSize类型} function RectWidth(Rect: TRect): Integer; {* 计算TRect的宽度} function RectHeight(Rect: TRect): Integer; {* 计算TRect的高度} procedure Delay(const uDelay: DWORD); {* 延时} procedure BeepEx(const Freq: WORD = 1200; const Delay: WORD = 1); {* 在Win9X下让喇叭发声} procedure ShowLastError; {* 显示Win32 Api运行结果信息} function GetHzPy(const AHzStr: string): string; {* 取汉字的拼音} function SoundCardExist: Boolean; {* 声卡是否存在}