VC++ 文件夹的打开

  文件夹打开的源码如下所示:

 

CString sPackPath;

BROWSEINFO bi;

WCHAR Buffer[MAX_PATH];

memset(Buffer,0,MAX_PATH);

bi.hwndOwner = this->GetSafeHwnd();

bi.pidlRoot = NULL;

bi.pszDisplayName = Buffer;

bi.lpszTitle =_T("请选择含有图片的文件夹");



bi.ulFlags = NULL;

bi.lpfn=NULL;

bi.iImage = IDR_MAINFRAME;

LPITEMIDLIST pIDList = SHBrowseForFolder(&bi);

if(pIDList)

{

    //保存打开文件夹的路径

    SHGetPathFromIDList(pIDList,Buffer);

    sPackPath = CString(Buffer);

}

else

{

    return;

}



LPMALLOC lpMalloc;

if (FAILED(SHGetMalloc(&lpMalloc)))

{

    return;

}



//释放

lpMalloc->Free(pIDList);

lpMalloc->Release();

 效果如下图所示:

 VC++ 文件夹的打开

 

 

你可能感兴趣的:(vc++)