BCB常用文件與字符串函數


VCL庫函數簡介

一.BORLAND C++ BUILDER VCL的內存管理函數

  1. AllocMem
  在隊中分配指定字節的內存塊,並將分配的每一個字節初始化為 0.函數原型如下:
  void * __fastcall AllocMem(Cardinal Size);

  2. SysFreeMem
  釋放所指定的內存塊.函數原型如下:
  int __fastcall SysFreeMem(void * P);

  3. SysReallocMem
  要求重新分配參數Size所指定的內存.函數原型如下:
  void * __fastcall SysReallocMem(void * P , int Size);

二.Borland C++ Builder VCL的文件操作函數

  1. FileOpen
  打開指定的文件,如果返回為正數,表示操作成功,返回值為文件句柄:如果返回值為-1,表示操作失敗,函數原型如下:
  int __fastcall FileOpen(const System::AnsiString FileName,int Mode);

  2. FileCreate
  以指定的文件名稱創建一個新的文件,如果返回為正數,表示操作成功,返回值為文件句柄,如果返回值為-1,表示操作失敗.函數原型如下:
  int __fastcall FileCreate(const System ::AnsiString FileName);

  3. FileRead
  從文件中讀取指定字節的數據到緩沖區中,函數返回實際讀取的字節數,函數原型如下;
  int __fastcall FileRead(int Handle,void *Buffer,int Count);

  4. FileWrite
  將緩沖區的數據寫入到指定的文件的當前位置中去如果操作成功,函數返回實際寫入的字節數,如果返回為-1,則表示操作產生錯誤,函數原型如下:
  int __fastcall FileWrite(int Handle,const void *Buffer,int Count);

  5. FileSeek
  調整文件指針到新的位置,如果操作成功,則返回新的文件位置,如果操作失敗,則函數返回-1,函數原型如下:
  int __fastcall FileSeek(int Handle,int Offset,int Origin);

  6. FileClose
  關閉指定的文件,函數原型如下:
  void __fastcall FileClose(int Handle);

  7. FileAge
  返回指定文件的時間標簽,如果操作失敗,則返回-1,函數原型如下:
  int __fastcall FileAge(const System::AnsiString FileName);

  8. FileExists
  用於測試指定的文件是否存在,如果存在返回真,否則返回假,函數原型如下:
  bool __fastcall FileExists(const System::AnsiString FileName);

  9. FileGetDate
  返回指定文件的DOS時間標簽,如果操作失敗,則近回-1,函數原型如下:
  int __fastcall FileGetDate(int Handle);

  10.FileSetDate
  更改指定文件的DOS時間標簽,如果操作成功,返回0,否則返回錯誤代碼,函數原型如下:
  int __fastcall FileSetDate(int Handle,int Age);

  11.FileGetAttr
  返回指定文件的屬性,如果操作失敗,則函數返回-1,函數原型如下;
  int __fastcall FileGetAttr(const System::AnsiString FileName);

  12.FileSetAttr
  更改指定文件的屬性參數,如果操作成功,則返回0,函數原型如下;
  int __fastcall FileSetAttr(const System::AnsiString FileName,int Attr);

  13.FindFirst
  在指定的文件目錄內,搜尋符合特定屬性參數的文件,如果成功地查找到符合條件的文件,
  則函數返回0,否則函數返回一個錯誤代碼,函數原型如下:
  int __fastcall FindFirst(const System::AnsiString Path,int Attr,TSearchRec &;F);

  14.FindNext
  繼續搜尋FindFirst所指定屬性參數的文件,如果成功地查找到符合條件的文件,則函數返回0,否則函數返回一個錯誤代碼,函數原型如下:
  int __fastcall FindNext(TSearchRec &;F);

  15.FindClose
  釋放FindFirst操作所申請的內存資源,函數原型如下:
  void __fastcall FindClose(TSearchRec &;F);

  16.DeleteFile
  在計算機磁盤中刪除指定的文件,如果操作成功,則函數返回真,函數原型如下:
  bool __fastcall DeleteFile(const AnsiString FileName);

  17.RenameFile
  更改指定文件的名稱,如果操作成功,則函數返回真,函數原型如下:
  bool __fastcall RenameFile(const AnsiString OldName, const AnsiString NewName);

  18.ChangeFileExt
  更改指定文件的擴展名,函數原型如下:
  AnsiString __fastcall ChangeFileExt(const AnsiString FileName,const AnsiString Extension);

  19.ExtractFilePath
  返回指定文件的工作路徑,函數原型如下:
  AnsiString __fastcall ExtractFilePath(const AnsiString FileName);

  20.ExtractFileDir
  返回指定文件的工作目錄,函數原型如下:
  AnsiString __fastcall ExtractFileDir(const AnsiString FileName);

  21.ExtractFileDrive
  返回指定文件的驅動器,函數原型如下:
  AnsiString __fastcall ExtractFileDrive(const AnsiString FileName);

  22.ExtractFileName
  返回指定文件的文件名及擴展名,函數原型如下:
  AnsiString __fastcall ExtractFileName(const AnsiString FileName);

  23.ExtractFileExt
  返回指定文件的擴展名,函數原型如下:
  AnsiString __fastcall ExtractFileExt(const AnsiString FileName);

三. Borland C++ Builder VCL的磁盤管理函數

  1. DiskFree
  返回指定磁盤的剩余空間,如果操作成功,返回剩余磁盤空間,如果操作失敗,則返回-1,函數原型如下:
  int __fastcall DiskFree(Byte Drive);

  2. DiskSize
  返回指定磁盤的空間,如果操作成功,返回磁盤空間,如果操作失敗,則返回-1,函數原型如下:
  int __fastcall DiskSize(Byte Drive);

  3. GetCurrentDir
  返回當前工作目錄,函數原型如下:
  AnsiString __fastcall GetCurrentDir();

  4. SetCurrentDir
  設置當前工作目錄,如果操作成功,則返回真,函數原型如下:
  bool __fastcall SetCurrentDir(const AnsiString Dir);

  5. CreateDir
  創建新的目錄,如果操作成功,返回真,否則返回假,函數原型如下:
  bool __fastcall CreateDir(const AnsiString Dir);

  6. RemoveDir
  刪除指定的目錄,如果操作成功,返回真,否則返回假,函數原型如下:
  bool __fastcall RemoveDir(const AnsiString Dir);

 

四. Borland C++ Builder VCL的字符串函數

  1. UpperCase
  將指定的AnsiString字符串轉換為大寫形式,函數原型如下:
  AnsiString __fastcall UpperCase(const AnsiString S);

  2. LowerCase
  將指定的AnsiString字符串轉換為小寫形式,函數原型如下:
  AnsiString __fastcall LowerCase(const AnsiString S);

  3. CompareStr
  比較兩個AnsiString字符串,函數原型如下:
  int __fastcall CompareStr(const AnsiString S1, const AnsiString S2);

  4. CompareText
  比較兩個AnsiString字符串,函數原型如下:
  int __fastcall CompareText(const AnsiString S1, const AnsiString S2);

  5. StrLen
  返回字符串的長度,函數原型如下:
  Cardinal __fastcall StrLen(const char * Str);

  6. StrEnd
  返回字符串結尾指針,函數原型如下:
  char * __fastcall StrEnd(const char * Str);

  7. StrMove
  從源字符串向目的字符串拷貝指定數目的字符,函數原型如下:
  char * __fastcall StrMove(char * Dest, const char * Source, Cardinal Count);

  8. StrCopy
  將源字符串拷貝到目的字符串中,函數原型如下:
  char * __fastcall StrCopy(char * Dest, const char * Source);

  9. StrECopy
  將源字符串拷貝到目的字符串中,並返回目的字符串結尾指針,函數原型如下:
  char * __fastcall StrECopy(char * Dest, const char * Source);

  10.StrLCopy
  將源字符串指定數目的字符拷貝到目的字符串中,並返回目的字符串指針,函數原型如下:
  char * __fastcall StrLCopy(char * Dest, const char * Source, Cardinal MaxLen);

  11.StrPCopy
  將AnsiString類型的源字符串拷貝到目的字符串中,並返回目的字符串指針,函數原型如下:
  char * __fastcall StrPCopy(char * Dest, const AnsiString Source);

  12.StrPLCopy
  將源字符串(AnsiString類型)指定數目的字符拷貝到目的字符串中,並返回目的字符串
指針,函數原型如下:
  char * __fastcall StrPLCopy(char * Dest, const AnsiString Source, Cardinal MaxLen);

  13.StrCat
  連接兩個字符串,並返回目的字符串指針,函數原型如下:
  char * __fastcall StrCat(char * Dest, const char * Source);

  14.StrLCat
  將指定數目的源字符串連接到目的字符串,並返回目的字符串指針,函數原型如下:
  char * __fastcall StrLCat(char * Dest, const char * Source, Cardinal MaxLen);

  15.StrComp
  兩個字符串相到比較,返回比較的結果,函數原型如下:
  int __fastcall StrComp(const char * Str1, const char * Str2);

  16.StrIComp
  兩個字符串相互比較(不論大小寫),返回比較的結果,函數原型如下:
  int __fastcall StrIComp(const char * Str1, const char * Str2);

  17.StrLComp
  對兩個字符串指定數目的字符進行比較操作,函數原型如下:
  int __fastcall StrLComp(const char * Str1, const char * Str2, Cardinal MaxLen);

  18.StrScan
  在指定的字符串中尋找特定的字符,並返回字符串中第一個特定字符的指針,函數原型如下:
  char * __fastcall StrScan(const char * Str, char Chr);

  19.StrRScan
  在指定的字符串中尋找特定的字符,並返回字符串中最后一個特定字符的指針,函數原型如下:
  char * __fastcall StrRScan(const char * Str, char Chr);

  20.StrPos
  在Strl所指定的字符串中尋找Str2所指定的子字符串,並返回Str2在Str2中第一個子字符的指針,函數原型如下:
  char * __fastcall StrPos(const char * Str1, const char * Str2);

  21.StrUpper
  將字符串轉換為大寫形式,函數原型如下:
  char * __fastcall StrUpper(char * Str);

  22.StrLower
  將字符串轉換為小寫形式,函數原型如下:
  char * __fastcall StrLower(char * Str);

  23.StrPas
  將指定的字符串轉換為AnsiString類型字符串對象,函數原型如下:
  AnsiString __fastcall StrPas(const char * Str);

  24.StrAlloc
  為字符串分配指定字節的內存,並返回內存指針,函數原型如下:
  char * __fastcall StrAlloc(Cardinal Size);

  25.StrBufSize
  返回*Str所指向內存的大小,函數原型如下:
  Cardinal __fastcall StrBufSize(const char * Str);

  26.StrNew
  在堆中為指定字符串分配空間,並將字符串拷貝到此空間中,函數原型如下:
  char * __fastcall StrNew(const char * Str);

五.  Borland C++ Builder VCL的數值轉換函數

  1. IntToStr
  將整數轉換為AnsiString字符串,函數原型如下:
  AnsiString __fastcall IntToStr(int Value);

  2. IntToHex
  將整數轉換為十六進制字符串,函數原型如下:
  AnsiString __fastcall IntToHex(int Value, int Digits);

  3. StrToInt
  將AnsiString字符串轉換為整數值,如果不能進行轉換,則產生EConvertError異常,
  函數原型如下:
  int __fastcall StrToInt(const AnsiString S);

  4. StrToIntDef
  將AnsiString字符串轉換為一個數值,函數原型如下:
  int __fastcall StrToIntDef(const System::AnsiString S,int Default);

  5. FloatToStr
  將浮點數轉換為AnsiString字符串,函數原型如下:
  AnsiString __fastcall FloatToStr(Extended Value);

  6. StrToFloat
  將AnsiString字符串轉換為一個浮點數值,函數原型如下:
  Extended __fastcall StrToFloat(const AnsiString S);

  7. FloatToStrF
  將浮點數轉換為指定格式的AnsiString字符串,函數原型如下:
  AnsiString __fastcall FloatToStrF(Extended Value, TFloatFormat Format,int Precision, int Digits);

 

六. Borland C++ Builder VCL的時間函數

  1. Date
  返回TDateTime對象,包含當前的年月日信息,函數原型如下:
  System::TDateTime __fastcall Date(void);

  2. Time
  返回TDateTime對象,包含當前的時間信息,函數原型如下:
  System::TDateTime __fastcall Time(void);

  3. Now
  返回TDateTime對象,獲取當前的日期和時間信息,函數原型如下:
  System::TDateTime __fastcall Now(void);

  4. DatetimeToString
  將TDateTime對象轉換為指定格式的字符串對象,函數原型如下:
  void __fastcall DateTimeToString(AnsiString &;Result, const AnsiString Format,System::TDateTime DateTime);

  5. DateToStr
  將TDateTime對象(包含當前年月日信息)轉換為字符串對象,函數原型如下:
  AnsiString __fastcall DateToStr(System::TDateTime Date);

  6. TimeToStr
  將當前日期轉換為字符串對象,函數原型如下:
  AnsiString __fastcall TimeToStr(System::TDateTime Time);

  7. DateTimetoStr
  將TDateTime對象轉換為字符串對象,函數原型如下:
  AnsiString __fastcall DateTimeToStr(System::TDateTime DateTime);

  8. StrToDate
  將字符串對象轉換為年月日對象,函數原型如下:
  System::TDateTime __fastcall StrToDate(const AnsiString S);

  9. StrToTime
  將字符串對象轉換時間對象,函數原型如下:
  System::TDateTime __fastcall StrToTime(const AnsiString S);

  10.StrToDateTime
  將字符串對象轉換為年月日時間對象,函數原型如下:
  System::TDateTime __fastcall StrToDateTime(const AnsiString S);

  11.DateTimeToSystemTime
  將TDateTime對象轉換為操作系統時間,函數原型如下:
  void __fastcall DateTimeToSystemTime(System::TDateTime DateTime, _SYSTEMTIME &;SystemTime);

  12.SystemTimeToDateTime
  將操作系統時間轉換為TDateTime對象,函數原型如下:
  System::TDateTime __fastcall SystemTimeToDateTime(const _SYSTEMTIME &;SystemTime);

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM