获取目录对话框

    BROWSEINFO bi;

    char szPathName[MAX_PATH];

    char szTitle[] = "选择路径";

    ZeroMemory(&bi, sizeof(BROWSEINFO));

 

    bi.hwndOwner = GetSafeHwnd();

    bi.pszDisplayName = szPathName;

    bi.lpszTitle = szTitle;

    bi.ulFlags = 0x0040 ; 

    CString str;

    CString strDir;  //选择的目录

 

    LPITEMIDLIST idl = SHBrowseForFolder(&bi);

    if(idl == NULL)

    {

        strDir= "";

        return;

    }

 

    SHGetPathFromIDList(idl, str.GetBuffer(MAX_PATH * 2));

    str.ReleaseBuffer();

    if(str != "" && str.GetAt(str.GetLength() - 1) != '\\')

        str += "\\";

    strDir = str;

posted on 2009-07-29 10:22  rainduck  阅读(170)  评论(0编辑  收藏  举报

导航