- HRESULT hr;
- LPSHELLFOLDER lpsf = NULL;
- hr = ::SHGetDesktopFolder(&lpsf);
- if (FAILED(hr))
- throw CString(_T("SHGetDestktopFolder error"));
- IEnumIDList* pEnumIDList = NULL;
- hr = lpsf->EnumObjects(::GetParent(m_hWnd), SHCONTF_FOLDERS | SHCONTF_NONFOLDERS,
- &pEnumIDList);
- if (FAILED(hr))
- throw CString(_T("lpsf->EnumObjects error"));
- LPITEMIDLIST pItemIDList;
- ULONG fetched;
- while (pEnumIDList->Next(1, &pItemIDList, &fetched) == S_OK)
- {
- ULONG attrs = SFGAO_HASSUBFOLDER | SFGAO_FOLDER;
- hr = lpsf->GetAttributesOf(1, (const struct _ITEMIDLIST**)&pItemIDList, &attrs);
- if (hr != S_OK)
- throw CString(_T("lpsf->GettAttributesOf error"));
- STRRET str;
- hr = lpsf->GetDisplayNameOf(pItemIDList, SHGDN_NORMAL, &str);
- if (hr != S_OK)
- throw CString(_T("lpsp->GetDisplayNameOf error"));
- TCHAR displayName[MAX_PATH];
- switch (str.uType)
- {
- case STRRET_CSTR:
- MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, str.cStr, strlen(str.cStr), displayName, MAX_PATH);
- break;
- case STRRET_WSTR:
- lstrcpy(displayName, str.pOleStr);
- break;
- default:
- throw CString(_T("lpsp->GetDisplayNameOf error"));
- }
- AfxMessageBox(displayName);
- }
[컴퓨터]-[휴지통]-[제어판]-[USER_NAME]-[라이브러리]-[네트워크]-...