#define WIN32_LEAN_AND_MEAN
#include <list>
#include <afxwin.h>
#include <stdio.h>
#include <windows.h>
#include <commctrl.h>
#include <tchar.h>
#include <iostream>
#include <atlstr.h>
#include "shlobj.h" //包含头文件
#include <CommonControls.h>
using namespace std;
typedef
struct tagLVITEM64
{
UINT mask;
int iItem;
int iSubItem;
UINT state;
UINT stateMask;
_int64 pszText;
int cchTextMax;
int iImage;
_int64 lParam;
#if (_WIN32_IE >= 0x0300)
int iIndent;
#endif
#if (_WIN32_WINNT >= 0x0501)
int iGroupId;
UINT cColumns;
_int64 puColumns;
#endif
#if _WIN32_WINNT >= 0x0600
_int64 piColFmt;
int iGroup;
#endif
} LVITEM64;
int main()
{
CoInitialize(NULL);
LPITEMIDLIST lpItemIDList;
SHFILEINFO shinfo;
TCHAR szPath[MAX_PATH];
::SHGetSpecialFolderLocation(NULL, CSIDL_DESKTOPDIRECTORY, &lpItemIDList);
::SHGetFileInfo((LPCTSTR)lpItemIDList, NULL, &shinfo,
sizeof(shinfo),
SHGFI_SYSICONINDEX | SHGFI_DISPLAYNAME | SHGFI_ICON | SHGFI_SMALLICON | SHGFI_PIDL);
::SHGetPathFromIDList(lpItemIDList, szPath);
CString strDisplayName, strPath;
strDisplayName.Format(_T(
"%s"), shinfo.szDisplayName);
strPath.Format(_T(
"%s"), szPath);
strPath = strPath + _T(
"\\aa.txt");
AfxMessageBox(strPath);
SHFILEINFO sfi;
SHGetFileInfo(strPath, -
1, &sfi,
sizeof(sfi), SHGFI_SYSICONINDEX);
IImageList* imageList;
HRESULT hResult = SHGetImageList(SHIL_EXTRALARGE, IID_IImageList, (
void**)&imageList);
if (hResult == S_OK) {
HICON hIcon;
hResult = (imageList)->GetIcon(sfi.iIcon, ILD_IMAGE | ILD_PRESERVEALPHA, &hIcon);
if (hResult == S_OK) {
int a =
1;
}
}
}