BORLAND C++常用VCL庫函數(shù)怎么樣
來源:易賢網(wǎng) 閱讀:914 次 日期:2015-03-23 15:29:59
溫馨提示:易賢網(wǎng)小編為您整理了“BORLAND C++常用VCL庫函數(shù)怎么樣”,方便廣大網(wǎng)友查閱!

VCL庫函數(shù)簡介

一.BORLAND C++ BUILDER VCL的內(nèi)存管理函數(shù)

1. AllocMem

在隊中分配指定字節(jié)的內(nèi)存塊,并將分配的每一個字節(jié)初始化為 0.函數(shù)原型如下:

void * __fastcall AllocMem(Cardinal Size);

2. SysFreeMem

釋放所指定的內(nèi)存塊.函數(shù)原型如下:

int __fastcall SysFreeMem(void * P);

3. SysReallocMem

要求重新分配參數(shù)Size所指定的內(nèi)存.函數(shù)原型如下:

void * __fastcall SysReallocMem(void * P , int Size);

二.Borland C++ Builder VCL的文件操作函數(shù)

1. FileOpen

打開指定的文件,如果返回為正數(shù),表示操作成功,返回值為文件句柄:如果返回值為-1,表示操作失敗,函數(shù)原型如下:

int __fastcall FileOpen(const System::AnsiString FileName,int Mode);

2. FileCreate

以指定的文件名稱創(chuàng)建一個新的文件,如果返回為正數(shù),表示操作成功,返回值為文件句柄,如果返回值為-1,表示操作失敗.函數(shù)原型如下:

int __fastcall FileCreate(const System ::AnsiString FileName);

3. FileRead

從文件中讀取指定字節(jié)的數(shù)據(jù)到緩沖區(qū)中,函數(shù)返回實際讀取的字節(jié)數(shù),函數(shù)原型如下;

int __fastcall FileRead(int Handle,void *Buffer,int Count);

4. FileWrite

將緩沖區(qū)的數(shù)據(jù)寫入到指定的文件的當前位置中去如果操作成功,函數(shù)返回實際寫入的字節(jié)數(shù),如果返回為-1,則表示操作產(chǎn)生錯誤,函數(shù)原型如下:

int __fastcall FileWrite(int Handle,const void *Buffer,int Count);

5. FileSeek

調(diào)整文件指針到新的位置,如果操作成功,則返回新的文件位置,如果操作失敗,則函數(shù)返回-1,函數(shù)原型如下:

int __fastcall FileSeek(int Handle,int Offset,int Origin);

6. FileClose

關(guān)閉指定的文件,函數(shù)原型如下:

void __fastcall FileClose(int Handle);

7. FileAge

返回指定文件的時間標簽,如果操作失敗,則返回-1,函數(shù)原型如下:

int __fastcall FileAge(const System::AnsiString FileName);

8. FileExists

用于測試指定的文件是否存在,如果存在返回真,否則返回假,函數(shù)原型如下:

bool __fastcall FileExists(const System::AnsiString FileName);

9. FileGetDate

返回指定文件的DOS時間標簽,如果操作失敗,則近回-1,函數(shù)原型如下:

int __fastcall FileGetDate(int Handle);

10.FileSetDate

更改指定文件的DOS時間標簽,如果操作成功,返回0,否則返回錯誤代碼,函數(shù)原型如下:

int __fastcall FileSetDate(int Handle,int Age);

11.FileGetAttr

返回指定文件的屬性,如果操作失敗,則函數(shù)返回-1,函數(shù)原型如下;

int __fastcall FileGetAttr(const System::AnsiString FileName);

12.FileSetAttr

更改指定文件的屬性參數(shù),如果操作成功,則返回0,函數(shù)原型如下;

int __fastcall FileSetAttr(const System::AnsiString FileName,int Attr);

13.FindFirst

在指定的文件目錄內(nèi),搜尋符合特定屬性參數(shù)的文件,如果成功地查找到符合條件的文件,

則函數(shù)返回0,否則函數(shù)返回一個錯誤代碼,函數(shù)原型如下:

int __fastcall FindFirst(const System::AnsiString Path,int Attr,TSearchRec &;F);

14.FindNext

繼續(xù)搜尋FindFirst所指定屬性參數(shù)的文件,如果成功地查找到符合條件的文件,則函數(shù)返回0,否則函數(shù)返回一個錯誤代碼,函數(shù)原型如下:

int __fastcall FindNext(TSearchRec &;F);

15.FindClose

釋放FindFirst操作所申請的內(nèi)存資源,函數(shù)原型如下:

void __fastcall FindClose(TSearchRec &;F);

16.DeleteFile

在計算機磁盤中刪除指定的文件,如果操作成功,則函數(shù)返回真,函數(shù)原型如下:

bool __fastcall DeleteFile(const AnsiString FileName);

17.RenameFile

更改指定文件的名稱,如果操作成功,則函數(shù)返回真,函數(shù)原型如下:

bool __fastcall RenameFile(const AnsiString OldName, const AnsiString NewName);

18.ChangeFileExt

更改指定文件的擴展名,函數(shù)原型如下:

AnsiString __fastcall ChangeFileExt(const AnsiString FileName,const AnsiString Extension);

19.ExtractFilePath

返回指定文件的工作路徑,函數(shù)原型如下:

AnsiString __fastcall ExtractFilePath(const AnsiString FileName);

20.ExtractFileDir

返回指定文件的工作目錄,函數(shù)原型如下:

AnsiString __fastcall ExtractFileDir(const AnsiString FileName);

21.ExtractFileDrive

返回指定文件的驅(qū)動器,函數(shù)原型如下:

AnsiString __fastcall ExtractFileDrive(const AnsiString FileName);

22.ExtractFileName

返回指定文件的文件名及擴展名,函數(shù)原型如下:

AnsiString __fastcall ExtractFileName(const AnsiString FileName);

23.ExtractFileExt

返回指定文件的擴展名,函數(shù)原型如下:

AnsiString __fastcall ExtractFileExt(const AnsiString FileName);

三. Borland C++ Builder VCL的磁盤管理函數(shù)

1. DiskFree

返回指定磁盤的剩余空間,如果操作成功,返回剩余磁盤空間,如果操作失敗,則返回-1,函數(shù)原型如下:

int __fastcall DiskFree(Byte Drive);

2. DiskSize

返回指定磁盤的空間,如果操作成功,返回磁盤空間,如果操作失敗,則返回-1,函數(shù)原型如下:

int __fastcall DiskSize(Byte Drive);

3. GetCurrentDir

返回當前工作目錄,函數(shù)原型如下:

AnsiString __fastcall GetCurrentDir();

4. SetCurrentDir

設(shè)置當前工作目錄,如果操作成功,則返回真,函數(shù)原型如下:

bool __fastcall SetCurrentDir(const AnsiString Dir);

5. CreateDir

創(chuàng)建新的目錄,如果操作成功,返回真,否則返回假,函數(shù)原型如下:

bool __fastcall CreateDir(const AnsiString Dir);

6. RemoveDir

刪除指定的目錄,如果操作成功,返回真,否則返回假,函數(shù)原型如下:

bool __fastcall RemoveDir(const AnsiString Dir);

四. Borland C++ Builder VCL的字符串函數(shù)

1. UpperCase

將指定的AnsiString字符串轉(zhuǎn)換為大寫形式,函數(shù)原型如下:

AnsiString __fastcall UpperCase(const AnsiString S);

2. LowerCase

將指定的AnsiString字符串轉(zhuǎn)換為小寫形式,函數(shù)原型如下:

AnsiString __fastcall LowerCase(const AnsiString S);

3. CompareStr

比較兩個AnsiString字符串,函數(shù)原型如下:

int __fastcall CompareStr(const AnsiString S1, const AnsiString S2);

4. CompareText

比較兩個AnsiString字符串,函數(shù)原型如下:

int __fastcall CompareText(const AnsiString S1, const AnsiString S2);

5. StrLen

返回字符串的長度,函數(shù)原型如下:

Cardinal __fastcall StrLen(const char * Str);

6. StrEnd

返回字符串結(jié)尾指針,函數(shù)原型如下:

char * __fastcall StrEnd(const char * Str);

7. StrMove

從源字符串向目的字符串拷貝指定數(shù)目的字符,函數(shù)原型如下:

char * __fastcall StrMove(char * Dest, const char * Source, Cardinal Count);

8. StrCopy

將源字符串拷貝到目的字符串中,函數(shù)原型如下:

char * __fastcall StrCopy(char * Dest, const char * Source);

9. StrECopy

將源字符串拷貝到目的字符串中,并返回目的字符串結(jié)尾指針,函數(shù)原型如下:

char * __fastcall StrECopy(char * Dest, const char * Source);

10.StrLCopy

將源字符串指定數(shù)目的字符拷貝到目的字符串中,并返回目的字符串指針,函數(shù)原型如下:

char * __fastcall StrLCopy(char * Dest, const char * Source, Cardinal MaxLen);

11.StrPCopy

將AnsiString類型的源字符串拷貝到目的字符串中,并返回目的字符串指針,函數(shù)原型如下:

char * __fastcall StrPCopy(char * Dest, const AnsiString Source);

12.StrPLCopy

將源字符串(AnsiString類型)指定數(shù)目的字符拷貝到目的字符串中,并返回目的字符串

指針,函數(shù)原型如下:

char * __fastcall StrPLCopy(char * Dest, const AnsiString Source, Cardinal MaxLen);

13.StrCat

連接兩個字符串,并返回目的字符串指針,函數(shù)原型如下:

char * __fastcall StrCat(char * Dest, const char * Source);

14.StrLCat

將指定數(shù)目的源字符串連接到目的字符串,并返回目的字符串指針,函數(shù)原型如下:

char * __fastcall StrLCat(char * Dest, const char * Source, Cardinal MaxLen);

15.StrComp

兩個字符串相到比較,返回比較的結(jié)果,函數(shù)原型如下:

int __fastcall StrComp(const char * Str1, const char * Str2);

16.StrIComp

兩個字符串相互比較(不論大小寫),返回比較的結(jié)果,函數(shù)原型如下:

int __fastcall StrIComp(const char * Str1, const char * Str2);

17.StrLComp

對兩個字符串指定數(shù)目的字符進行比較操作,函數(shù)原型如下:

int __fastcall StrLComp(const char * Str1, const char * Str2, Cardinal MaxLen);

18.StrScan

在指定的字符串中尋找特定的字符,并返回字符串中第一個特定字符的指針,函數(shù)原型如下:

char * __fastcall StrScan(const char * Str, char Chr);

19.StrRScan

在指定的字符串中尋找特定的字符,并返回字符串中最后一個特定字符的指針,函數(shù)原型如下:

char * __fastcall StrRScan(const char * Str, char Chr);

20.StrPos

在Strl所指定的字符串中尋找Str2所指定的子字符串,并返回Str2在Str2中第一個子字符的指針,函數(shù)原型如下:

char * __fastcall StrPos(const char * Str1, const char * Str2);

21.StrUpper

將字符串轉(zhuǎn)換為大寫形式,函數(shù)原型如下:

char * __fastcall StrUpper(char * Str);

22.StrLower

將字符串轉(zhuǎn)換為小寫形式,函數(shù)原型如下:

char * __fastcall StrLower(char * Str);

23.StrPas

將指定的字符串轉(zhuǎn)換為AnsiString類型字符串對象,函數(shù)原型如下:

AnsiString __fastcall StrPas(const char * Str);

24.StrAlloc

為字符串分配指定字節(jié)的內(nèi)存,并返回內(nèi)存指針,函數(shù)原型如下:

char * __fastcall StrAlloc(Cardinal Size);

25.StrBufSize

返回*Str所指向內(nèi)存的大小,函數(shù)原型如下:

Cardinal __fastcall StrBufSize(const char * Str);

26.StrNew

在堆中為指定字符串分配空間,并將字符串拷貝到此空間中,函數(shù)原型如下:

char * __fastcall StrNew(const char * Str);

五. Borland C++ Builder VCL的數(shù)值轉(zhuǎn)換函數(shù)

1. IntToStr

將整數(shù)轉(zhuǎn)換為AnsiString字符串,函數(shù)原型如下:

AnsiString __fastcall IntToStr(int Value);

2. IntToHex

將整數(shù)轉(zhuǎn)換為十六進制字符串,函數(shù)原型如下:

AnsiString __fastcall IntToHex(int Value, int Digits);

3. StrToInt

將AnsiString字符串轉(zhuǎn)換為整數(shù)值,如果不能進行轉(zhuǎn)換,則產(chǎn)生EConvertError異常,

函數(shù)原型如下:

int __fastcall StrToInt(const AnsiString S);

4. StrToIntDef

將AnsiString字符串轉(zhuǎn)換為一個數(shù)值,函數(shù)原型如下:

int __fastcall StrToIntDef(const System::AnsiString S,int Default);

5. FloatToStr

將浮點數(shù)轉(zhuǎn)換為AnsiString字符串,函數(shù)原型如下:

AnsiString __fastcall FloatToStr(Extended Value);

6. StrToFloat

將AnsiString字符串轉(zhuǎn)換為一個浮點數(shù)值,函數(shù)原型如下:

Extended __fastcall StrToFloat(const AnsiString S);

7. FloatToStrF

將浮點數(shù)轉(zhuǎn)換為指定格式的AnsiString字符串,函數(shù)原型如下:

AnsiString __fastcall FloatToStrF(Extended Value, TFloatFormat Format,int Precision, int Digits);

六. Borland C++ Builder VCL的時間函數(shù)

1. Date

返回TDateTime對象,包含當前的年月日信息,函數(shù)原型如下:

System::TDateTime __fastcall Date(void);

2. Time

返回TDateTime對象,包含當前的時間信息,函數(shù)原型如下:

System::TDateTime __fastcall Time(void);

3. Now

返回TDateTime對象,獲取當前的日期和時間信息,函數(shù)原型如下:

System::TDateTime __fastcall Now(void);

4. DatetimeToString

將TDateTime對象轉(zhuǎn)換為指定格式的字符串對象,函數(shù)原型如下:

void __fastcall DateTimeToString(AnsiString &;Result, const AnsiString Format,System::TDateTime DateTime);

5. DateToStr

將TDateTime對象(包含當前年月日信息)轉(zhuǎn)換為字符串對象,函數(shù)原型如下:

AnsiString __fastcall DateToStr(System::TDateTime Date);

6. TimeToStr

將當前日期轉(zhuǎn)換為字符串對象,函數(shù)原型如下:

AnsiString __fastcall TimeToStr(System::TDateTime Time);

7. DateTimetoStr

將TDateTime對象轉(zhuǎn)換為字符串對象,函數(shù)原型如下:

AnsiString __fastcall DateTimeToStr(System::TDateTime DateTime);

8. StrToDate

將字符串對象轉(zhuǎn)換為年月日對象,函數(shù)原型如下:

System::TDateTime __fastcall StrToDate(const AnsiString S);

9. StrToTime

將字符串對象轉(zhuǎn)換時間對象,函數(shù)原型如下:

System::TDateTime __fastcall StrToTime(const AnsiString S);

10.StrToDateTime

將字符串對象轉(zhuǎn)換為年月日時間對象,函數(shù)原型如下:

System::TDateTime __fastcall StrToDateTime(const AnsiString S);

11.DateTimeToSystemTime

將TDateTime對象轉(zhuǎn)換為操作系統(tǒng)時間,函數(shù)原型如下:

void __fastcall DateTimeToSystemTime(System::TDateTime DateTime, _SYSTEMTIME &;SystemTime);

12.SystemTimeToDateTime

將操作系統(tǒng)時間轉(zhuǎn)換為TDateTime對象,函數(shù)原型如下:

System::TDateTime __fastcall SystemTimeToDateTime(const _SYSTEMTIME &;SystemTime);

更多信息請查看IT技術(shù)專欄

更多信息請查看技術(shù)文章
易賢網(wǎng)手機網(wǎng)站地址:BORLAND C++常用VCL庫函數(shù)怎么樣
關(guān)于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 加入群交流 | 手機站點 | 投訴建議
工業(yè)和信息化部備案號:滇ICP備2023014141號-1 云南省教育廳備案號:云教ICP備0901021 滇公網(wǎng)安備53010202001879號 人力資源服務許可證:(云)人服證字(2023)第0102001523號
聯(lián)系電話:0871-65317125(9:00—18:00) 獲取招聘考試信息及咨詢關(guān)注公眾號:hfpxwx
咨詢QQ:526150442(9:00—18:00)版權(quán)所有:易賢網(wǎng)