1. 程式人生 > >VC6.0實現開啟檔案與開啟資料夾選項

VC6.0實現開啟檔案與開啟資料夾選項

1 VC6.0實現開啟檔案選項

    CFileDialog dlg(true);
    CString path;
    if(dlg.DoModal()!=IDOK)
    {
       return;
    }
    else
         path=dlg.GetPathName();

2 VC6.0實現開啟資料夾選項

static TCHAR strDirName[MAX_PATH];
    BROWSEINFO bi;
    CString szString = TEXT("選擇一個原始檔子資料夾");
    bi.hwndOwner = this->GetSafeHwnd();
bi.pidlRoot = NULL; bi.pszDisplayName = strDirName; bi.lpszTitle = szString; bi.ulFlags = BIF_BROWSEFORCOMPUTER | BIF_DONTGOBELOWDOMAIN | BIF_RETURNONLYFSDIRS; bi.lpfn = NULL; bi.lParam = 0; bi.iImage = 0; LPITEMIDLIST pItemIDList = SHBrowseForFolder(&bi); if(pItemIDList == NULL) { return ;
} SHGetPathFromIDList(pItemIDList, strDirName); SetDlgItemText(IDC_EDIT1,strDirName);