在vc 中浏览文件夹

void CTestBrowseDlg::OnBrowse() 
{
    CString str;
    BROWSEINFO bi;
     char name[MAX_PATH];
    ZeroMemory(&bi, sizeof(BROWSEINFO));
    bi.hwndOwner=GetSafeHwnd();
    bi.pszDisplayName=name;
    bi.lpszTitle="Select folder";
    bi.ulFlags=BIF_USENEWUI;
    LPITEMIDLIST idl=SHBrowseForFolder(&bi);
     if(idl==NULL)
         return;
    SHGetPathFromIDList(idl,str.GetBuffer(MAX_PATH));
    str.ReleaseBuffer();
    m_Path=str;
     if(str.GetAt(str.GetLength()-1)!=''\\'')
        m_Path+="\\";
    UpdateData(FALSE);
}

猜你喜欢

转载自blog.csdn.net/eamon100/article/details/89334188
0条评论
添加一条新回复