VCL (Visual Component Library) 提供大量跨平台封裝函數,簡化 Windows API 直接呼叫的複雜度。本手冊按功能分類彙整核心函數原型、參數與回傳值,供 C++Builder 開發者快速查閱。
| 函數 | 原型 | 回傳值/說明 |
| FileOpen | `int __fastcall FileOpen(const AnsiString& FileName, int Mode)` | >0: 句柄; -1: 失敗。Mode: `fmOpenRead`/`fmOpenWrite`/`fmOpenReadWrite` + `fmShareDenyNone` 等 |
| FileCreate | `int __fastcall FileCreate(const AnsiString& FileName)` | >0: 句柄; -1: 失敗 (已存在不覆蓋) |
| FileRead | `int __fastcall FileRead(int Handle, void* Buffer, int Count)` | 實際讀取位元組數 |
| FileWrite | `int __fastcall FileWrite(int Handle, const void* Buffer, int Count)` | 實際寫入位元組數; -1: 錯誤 |
| FileSeek | `int __fastcall FileSeek(int Handle, int Offset, int Origin)` | 新位置; -1: 錯誤。Origin: 0=始, 1=當前, 2=末 |
| FileClose | `void __fastcall FileClose(int Handle)` | 關閉句柄 |
| FileAge | `int __fastcall FileAge(const AnsiString& FileName)` | DOS 時間戳; -1: 不存在 |
| FileExists | `bool __fastcall FileExists(const AnsiString& FileName)` | 存在傳 true |
| FileGetDate | `int __fastcall FileGetDate(int Handle)` | DOS 時間戳; -1: 錯誤 |
| FileSetDate | `int __fastcall FileSetDate(int Handle, int Age)` | 0: 成功; 錯誤碼 |
| FileGetAttr | `int __fastcall FileGetAttr(const AnsiString& FileName)` | 屬性位元組合; -1: 錯誤 |
| FileSetAttr | `int __fastcall FileSetAttr(const AnsiString& FileName, int Attr)` | 0: 成功 |
| 函數 | 原型 | 說明 |
| FindFirst | `int __fastcall FindFirst(const AnsiString& Path, int Attr, TSearchRec& F)` | 0: 找到; 錯誤碼。Attr: `faReadOnly`/`faHidden`/`faSysFile`/`faDirectory`/`faArchive`/`faAnyFile` |
| FindNext | `int __fastcall FindNext(TSearchRec& F)` | 0: 找到下一個; 錯誤碼 |
| FindClose | `void __fastcall FindClose(TSearchRec& F)` | **必須呼叫** 釋放 `FindFirst` 內部配置記憶體 |
| DeleteFile | `bool __fastcall DeleteFile(const AnsiString& FileName)` | 成功 true |
| RenameFile | `bool __fastcall RenameFile(const AnsiString& Old, const AnsiString& New)` | 成功 true |
| ChangeFileExt | `AnsiString __fastcall ChangeFileExt(const AnsiString& FileName, const AnsiString& Ext)` | 回傳新檔名 (含點) |
| ExtractFilePath | `AnsiString __fastcall ExtractFilePath(const AnsiString& FileName)` | 目錄路徑 (含反斜線) |
| ExtractFileDir | `AnsiString __fastcall ExtractFileDir(const AnsiString& FileName)` | 目錄路徑 (不含反斜線) |
| ExtractFileDrive | `AnsiString __fastcall ExtractFileDrive(const AnsiString& FileName)` | 磁碟機代號 (如 `C:`) |
| ExtractFileName | `AnsiString __fastcall ExtractFileName(const AnsiString& FileName)` | 檔名+副檔名 |
| ExtractFileExt | `AnsiString __fastcall ExtractFileExt(const AnsiString& FileName)` | 副檔名 (含點) |
| DiskFree | `int __fastcall DiskFree(Byte Drive)` | 剩餘位元組; -1: 錯誤。Drive: 0=當前, 1=A, 2=B... |
| DiskSize | `int __fastcall DiskSize(Byte Drive)` | 總位元組; -1: 錯誤 |
| GetCurrentDir | `AnsiString __fastcall GetCurrentDir()` | 當前工作目錄 |
| SetCurrentDir | `bool __fastcall SetCurrentDir(const AnsiString& Dir)` | 成功 true |
| CreateDir | `bool __fastcall CreateDir(const AnsiString& Dir)` | 成功 true |
| RemoveDir | `bool __fastcall RemoveDir(const AnsiString& Dir)` | 成功 true (目錄必須為空) |
| 分類 | 函數 | 用途 |
| 大小寫 | `UpperCase` / `LowerCase` | `AnsiString` 版,回傳新字串 |
| `StrUpper` / `StrLower` | 原地修改 `char*`,回傳指標 |
| 比較 | `CompareStr` / `CompareText` | `AnsiString` 版,區分/不區分大小寫,回傳 -1/0/1 |
| `StrComp` / `StrIComp` / `StrLComp` | C 字串比較,指定長度版 |
| 複製/移動/連接 | `StrCopy` / `StrECopy` / `StrLCopy` | 複製 C 字串,`ECopy` 回傳尾端指標 |
| `StrPCopy` / `StrPLCopy` | `AnsiString` → `char*` 複製 |
| `StrCat` / `StrLCat` | 連接 C 字串 |
| `StrMove` | 移動指定字元數 `Source` → `Dest` |
| 查找/掃描 | `StrScan` / `StrRScan` | 正向/反向掃描單一字元,回傳指標 |
| `StrPos` | 尋找子字串,回傳首次出現指標 |
| `StrLen` / `StrEnd` | 長度 / 尾端指標 |
| 記憶體/轉換 | `StrAlloc` / `StrBufSize` / `StrNew` | 配置/查詢/複製字串緩衝區 |
| `StrPas` | `char*` → `AnsiString` |
| `AnsiString` 方法 | `c_str()`/`Length()`/`Pos()`/`SubString()`/`Trim()`... 現代首選 |
| 函數 | 原型 | 說明 |
| IntToStr | `AnsiString __fastcall IntToStr(int Value)` | 整數 → 字串 |
| IntToHex | `AnsiString __fastcall IntToHex(int Value, int Digits)` | 整數 → 十六進位字串 (固定寬度) |
| StrToInt | `int __fastcall StrToInt(const AnsiString& S)` | 字串 → 整數,失敗拋 `EConvertError` |
| StrToIntDef | `int __fastcall StrToIntDef(const AnsiString& S, int Default)` | 失敗回傳 `Default`,不拋例外 |
| FloatToStr | `AnsiString __fastcall FloatToStr(Extended Value)` | 浮點數 → 字串 (預設格式) |
| StrToFloat | `Extended __fastcall StrToFloat(const AnsiString& S)` | 字串 → 浮點數 |
| FloatToStrF | `AnsiString __fastcall FloatToStrF(Extended Value, TFloatFormat Format, int Precision, int Digits)` | 格式化浮點數字串 (`ffFixed`/`ffScientific`/`ffGeneral`/`ffNumber`/`ffCurrency`) |
| 函數 | 原型 | 說明 |
| Date | `TDateTime __fastcall Date()` | 當前日期 (整數部 = 天數) |
| Time | `TDateTime __fastcall Time()` | 當前時間 (小數部 = 當天比例) |
| Now | `TDateTime __fastcall Now()` | 當前日期時間 |
| DateTimeToString | `void __fastcall DateTimeToString(AnsiString& Result, const AnsiString& Format, TDateTime DateTime)` | 自訂格式化 (格式字串參考 `FormatDateTime`) |
| DateToStr | `AnsiString __fastcall DateToStr(TDateTime Date)` | 日期 → 短日期字串 (區域設定) |
| TimeToStr | `AnsiString __fastcall TimeToStr(TDateTime Time)` | 時間 → 短時間字串 |
| DateTimeToStr | `AnsiString __fastcall DateTimeToStr(TDateTime DateTime)` | 日期時間 → 完整字串 |
| StrToDate | `TDateTime __fastcall StrToDate(const AnsiString& S)` | 字串 → 日期 |
| StrToTime | `TDateTime __fastcall StrToTime(const AnsiString& S)` | 字串 → 時間 |
| StrToDateTime | `TDateTime __fastcall StrToDateTime(const AnsiString& S)` | 字串 → 日期時間 |
| DateTimeToSystemTime | `void __fastcall DateTimeToSystemTime(TDateTime DT, _SYSTEMTIME& ST)` | 轉 Win32 `SYSTEMTIME` 結構 |
| SystemTimeToDateTime | `TDateTime __fastcall SystemTimeToDateTime(const _SYSTEMTIME& ST)` | Win32 `SYSTEMTIME` → `TDateTime` |