|
在列表控件上显示设置里的图标,有的大有的小,如何才能拉伸致一样大?还有个问题,如何知道设置里的图标是在个人还是在系统还是在连接里?谢谢
void GetFileIcon(DWORD fpid,SHFILEINFO *info)
{
ZeroMemory(info,sizeof SHFILEINFO);
TCHAR name[MAX_PATH];
HANDLE hhe=::OpenProcess(NULL,NULL,fpid);
::GetModuleFileName((HMODULE)hhe,name,MAX_PATH);
CloseHandle(hhe);
SHGetFileInfo(name,0,info,sizeof SHFILEINFO,SHGFI_ICON|isBigIcon);
}
void SetImageIcon(int ls)
{
if(ls==0)
ls=2;
ListView_DeleteAllItems(hList);
HIMAGELIST il=ListView_GetImageList(hList,LVSIL_SMALL);
if(il==hil)
{
ListView_SetImageList(hList,ohil,LVSIL_SMALL);
ImageList_Destroy(hil);
}
hil=ImageList_Create(iconsize*ls,iconsize*ls,ILC_COLORDDB | ILC_MASK,1,0);
ohil=ListView_SetImageList(hList,hil,LVSIL_SMALL);
}
union {
NEWCPLINFOA NewCplInfoA;
NEWCPLINFOW NewCplInfoW;
} Newcpl;
void GetControls()
{
SetCursor(LoadCursor(NULL, IDC_WAIT));
SendMessage(hList,WM_SETREDRAW,FALSE,NULL);
SetImageIcon(isBigIcon);
LVITEM li;
ZeroMemory(&li,sizeof li);
li.mask=LVIF_TEXT|LVIF_IMAGE|LVIF_PARAM;
li.iItem=0;
li.cchTextMax=MAX_PATH;
// ImageList_SetIconSize(hil,32,32);
HANDLE hFind; // file handle
WIN32_FIND_DATA FindFileData;
TCHAR DirPath[]=L"\\windows\\*.cpl";
hFind = FindFirstFile(DirPath,&FindFileData); // find the first file
if(hFind != INVALID_HANDLE_VALUE)
{
bool bSearch = true;
while(bSearch)
{
HINSTANCE m_hInst=::LoadLibrary(FindFileData.cFileName);
LPCPlAppletType pfnCPlApplet =(LPCPlAppletType)GetProcAddress(m_hInst,L"CPlApplet");
pfnCPlApplet(NULL,CPL_INIT,0,0);
for (int i=0;i
{
Newcpl.NewCplInfoA.dwSize = 0;
Newcpl.NewCplInfoA.dwFlags = 0;
pfnCPlApplet(NULL,CPL_NEWINQUIRE,i,(DWORD)&Newcpl);
{
if (Newcpl.NewCplInfoA.dwSize != sizeof(NEWCPLINFOW))
{
/*
CPLINFO CInfo;
pfnCPlApplet(NULL,CPL_INQUIRE,i,(long)&CInfo);
LoadString(m_hInst,CInfo.idName,WinName,MAX_PATH);
li.pszText=WinName;
li.iImage=ImageList_AddIcon(hil,LoadIcon(m_hInst,MAKEINTRESOURCE(CInfo.idIcon)));
ListView_InsertItem(hList,&li);
*/
}
else
{
// li.lParam=pe.th32ProcessID;
li.pszText=Newcpl.NewCplInfoW.szName;
li.iImage=ImageList_AddIcon(hil,Newcpl.NewCplInfoW.hIcon);
ListView_InsertItem(hList,&li);
}
}
}
pfnCPlApplet(NULL,CPL_EXIT,0,0);
FreeLibrary(m_hInst);
if(FindNextFile(hFind,&FindFileData))
{
}
else
{
if(GetLastError() == ERROR_NO_MORE_FILES) // no more files there
bSearch = false;
else
{
FindClose(hFind);
break;
}
}
}
}
FindClose(hFind);
SendMessage(hList,WM_SETREDRAW,TRUE,NULL);
SetListRect();
SetCursor(NULL);
}
|
|