一.選擇文件夾對話框。
#include <shlobj.h>
........
BROWSEINFO bi;
LPITEMIDLIST pDir;
char path[MAX_PATH]={"C:\\"};
bi.hwndOwner =Handle;
bi.lpszTitle ="請選擇一個目錄,該目錄是你要保存數據的目錄.";
bi.pszDisplayName =path;
bi.ulFlags =BIF_RETURNONLYFSDIRS;//BIF_BROWSEFORCOMPUTER ;
bi.pidlRoot =NULL;
bi.lpfn =NULL;
bi.lParam =124;
pDir=SHBrowseForFolder(&bi);
if(pDir!=NULL)
{
SHGetPathFromIDList(pDir,path);
edtFileName->Text=(AnsiString)path;
}
Public Const BIF_BROWSEFORCOMPUTER = &H1000 注释:允许浏览计算机
Public Const BIF_BROWSEFORPRINTER = &H2000 注释:允许浏览打印机文件夹
Public Const BIF_BROWSEINCLUDEFILES = &H4000 注释:允许同时浏览文件(需IE4)
Public Const BIF_DONTGOBELOWDOMAIN = &H2 注释:强制用户停留在网上邻居中
Public Const BIF_EDITBOX = &H10 注释:可在输入框中直接输入文件夹名(需IE4)
Public Const BIF_RETURNFSANCESTORS = &H8 注释:返回文件系统祖先?
Public Const BIF_RETURNONLYFSDIRS = &H1 注释:仅允许浏览文件系统
Public Const BIF_STATUSTEXT = &H4 注释:显示状态栏
Public Const BIF_USENEWUI = &H40 注释:使用新界面(仅支持Win2000、WinME)
Public Const BIF_VALIDATE = &H20 注释:若输入一个非法文件夹名,就返回
BFFM_VALIDATEFAILED 给回调函数
二.創建多層文件夾
1.可以用API CreateDirectory.
CreateDirectory只能創建單層目錄。
2.使用BCB中自帶的函數ForceDirectories(AnsiString path);
#include <filectrl.hpp>
三.操作ini文件
#incldue <inifiles.hpp>
1.讀操作
AnsiString strPath,strFile;
strPath=ExtractFilePath(Application->ExeName);
strFile=strPath+"reademail.ini";
TIniFile *ini=new TIniFile(strFile);
//ini->
edtFileName->Text=ini->ReadString("Config","FileName","");
edtSheet->Text=ini->ReadString("Config","Sheet","1");
edtColumn->Text=ini->ReadString("Config","Column","1");
edtEmailPath->Text=ini->ReadString("Config","EmailPath",strPath);
delete ini;
2.寫操作
AnsiString strPath,strFile;
strPath=ExtractFilePath(Application->ExeName);
strFile=strPath+"reademail.ini";
TIniFile *ini=new TIniFile(strFile);
//ini->
ini->WriteString("Config","FileName",edtFileName->Text);
ini->WriteString("Config","Sheet",edtSheet->Text);
ini->WriteString("Config","Column",edtColumn->Text);
ini->WriteString("Config","EmailPath",edtEmailPath->Text);
delete ini;