资源描述:
《BCB通用函数库》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、1.BCB通用函數庫//获得计算机名AnsiStringGetComputerName(){charname[MAX_COMPUTERNAME_LENGTH+1];DWORDsize=MAX_COMPUTERNAME_LENGTH+1;if(GetComputerName(name,&size))returnAnsiString(name);return"";} //获得当前用户名AnsiStringGetUserName(){charusername[MAX_COMPUTERNAME_LENGTH+1];DWORDsize=MAX_CO
2、MPUTERNAME_LENGTH+1;if(GetUserName(username,&size))returnAnsiString(username);return"";} //Windows文件夹AnsiStringGetWindowsDir(){Stringpath;path.SetLength(MAX_PATH);path.SetLength(GetWindowsDirectory(path.c_str(),path.Length()));returnpath;} //System文件夹AnsiStringGetSystemDi
3、r(){Stringpath;path.SetLength(MAX_PATH);path.SetLength(GetSystemDirectory(path.c_str(),path.Length()));returnpath;} //Temp文件夹AnsiStringGetTempDir(){Stringpath;path.SetLength(MAX_PATH);path.SetLength(GetTempPath(MAX_PATH,path.c_str()));returnpath;}//当前文件夹AnsiStringGetCurrD
4、ir(){Stringpath;path.SetLength(MAX_PATH);path.SetLength(GetCurrentDirectory(MAX_PATH,path.c_str()));returnpath;//returnExtractFilePath(Application->ExeName);//returnExtractFilePath(ParamStr(0));} //获得IE版本AnsiStringGetIEVersion(){AnsiStringstrReturn;LPCTSTRData_Set="SOFTWA
5、RE\Microsoft\InternetExplorer\";HKEYhKEY;longret0=::RegOpenKeyEx(HKEY_LOCAL_MACHINE,//rootkeyData_Set,//要访问的键的位置;0,//必须为0;KEY_READ,//以查询的方式访问注册表;&hKEY);//hKEY保存此函数所打开的键的句柄。if(ret0!=ERROR_SUCCESS)return"Unavailable";else{charver[MAX_COMPUTERNAME_LENGTH+1];DWORDtype=REG_
6、SZ;DWORDcbData=40;longret1=::RegQueryValueEx(hKEY,//所打开的键的句柄"Version",//要查询的键值名NULL,&type,//查询数据的类型ver,//保存所查询的数据&cbData);//预设置的数据长度if(ret1!=ERROR_SUCCESS)return"Unavailable";elsestrReturn=AnsiString(ver);}::RegCloseKey(hKEY);returnstrReturn;}voidJpg2Bmp(StringJpgFile,Str
7、ingBmpFile)//将Jpg文件转换为Bmp文件{TJPEGImage*MyJPEG=newTJPEGImage;try{MyJPEG->LoadFromFile(JpgFile);//图片位置Graphics::TBitmap*MyBMP=newGraphics::TBitmap;MyBMP->Assign(MyJPEG);MyBMP->SaveToFile(BmpFile);//保存路径deleteMyBMP;}__finally{deleteMyJPEG;}}voidBmp2Jpg(StringBmpName,StringJp
8、gName)//将bmp文件转换为jpg文件{Graphics::TBitmap*MyBMP=newGraphics::TBitmap;try{MyBMP->LoadFromFile(BmpN