SHGetSpecialFolderLocation 的使用方法

详情,请查看MSDN:

http://msdn.microsoft.com/en-us/library/bb762203%28VS.85%29.aspx

 

这里只提供一小段代码:

 

void CDlgTestDlg::OnBnClickedOk() { LPITEMIDLIST pidl; TCHAR szPath [MAX_PATH]; if(SUCCEEDED( SHGetSpecialFolderLocation ( NULL, CSIDL_FAVORITES, &pidl ))) { if ( SHGetPathFromIDList ( pidl, szPath )) { CString sDisplayName; SHFILEINFO sfi; ZeroMemory(&sfi,sizeof(sfi)); UINT uFlags = SHGFI_PIDL | SHGFI_DISPLAYNAME; SHGetFileInfo((LPCTSTR)pidl, 0, &sfi, sizeof(SHFILEINFO), uFlags); sDisplayName = sfi.szDisplayName; CString szDisplay; szDisplay.Format(_T(" %s /n /n %s"),szPath, sDisplayName); GetDlgItem(IDC_STATIC)->SetWindowText(szDisplay); CoTaskMemFree(pidl); //free the resource } } }

你可能感兴趣的:(C/C++,path,null)