EnumResourceNames枚举资源
来源:互联网 发布:高校网络舆情工作方案 编辑:程序博客网 时间:2024/05/16 02:17
CImageList cImageListIcons;
{
CDialog::OnInitDialog();
SetIcon(m_hIcon, TRUE);// Set big icon
SetIcon(m_hIcon, FALSE);// Set small icon
char szPath[256]={0};
GetModuleFileName(NULL,szPath,256);
SetDlgItemText(IDC_EDIT1,szPath);
cImageListIcons.Create(35,35,ILC_COLOR24|ILC_MASK,0,0);
//关联
m_listCtrlIcons.SetImageList(&cImageListIcons,LVSIL_NORMAL);
return TRUE; // return TRUE unless you set the focus to a control
}
//参数结构体
struct LParam
{
CListBox*pListBox;
CListCtrl*pListCtrl;
};
int index=0;
//枚举
BOOL CALLBACK EnumResNameProc(
HMODULE hModule,
LPCTSTR lpszType,
LPTSTR lpszName,
LPARAM lParam
)
{
LParam *lpTmp=(LParam*)lParam;
if(lpszType==RT_GROUP_ICON)
{
//load
HICON hic=LoadIcon(hModule,lpszName);
int nImageIndex= cImageListIcons.Add(hic);
//Icon id
DWORD dwIconID=(DWORD)lpszName;
char szFormat[50]={0};
sprintf(szFormat,"Icon[%d]",dwIconID);
lpTmp->pListBox->AddString(szFormat);
lpTmp->pListCtrl->InsertItem(index,szFormat,nImageIndex);
index++;
DestroyIcon(hic);
}
else if(lpszType== RT_BITMAP)
{
HBITMAP bit=LoadBitmap(hModule,lpszName);
CBitmap *bitmap=CBitmap::FromHandle(bit);
int nImageIndex= cImageListIcons.Add(bitmap,RGB(255,255,255));
//Icon id
DWORD dwIconID=(DWORD)lpszName;
char szFormat[50]={0};
sprintf(szFormat,"Bitmap[%d]",dwIconID);
lpTmp->pListBox->AddString(szFormat);
lpTmp->pListCtrl->InsertItem(nImageIndex,szFormat,nImageIndex);
DeleteObject(bit);
}else if (lpszType==RT_DIALOG)
{
DWORD dwIconID=(DWORD)lpszName;
char szFormat[50]={0};
sprintf(szFormat,"Dialog[%d]",dwIconID);
lpTmp->pListBox->AddString(szFormat);
}else if (lpszType==RT_GROUP_CURSOR)
{
HCURSOR hCursor= LoadCursor(hModule,lpszName);
DWORD dwIconID=(DWORD)lpszName;
char szFormat[50]={0};
sprintf(szFormat,"Cursor[%d]",dwIconID);
int nIndex=cImageListIcons.Add((HICON)hCursor);
lpTmp->pListBox->AddString(szFormat);
lpTmp->pListCtrl->InsertItem(nIndex,szFormat,nIndex);
DestroyCursor(hCursor);
}
return TRUE;
}
void CEnumRsrcDlg::OnButton1()
{
//清空
m_listCtrlIcons.DeleteAllItems();
m_listBoxIconIds.ResetContent();
LParam lp;
lp.pListBox=&m_listBoxIconIds;
lp.pListCtrl=&m_listCtrlIcons;
char szPath[256]={0};
GetDlgItemText(IDC_EDIT1,szPath,256);
HMODULE hModule=LoadLibrary(szPath);
//枚举ICON
EnumResourceNames(hModule,RT_GROUP_ICON,EnumResNameProc,(LPARAM)&lp);
//枚举bitmap
EnumResourceNames(hModule,RT_BITMAP,EnumResNameProc,(LPARAM)&lp);
//枚举dialog
EnumResourceNames(hModule,RT_DIALOG,EnumResNameProc,(LPARAM)&lp);
//枚举cursor
EnumResourceNames(hModule,RT_GROUP_CURSOR,EnumResNameProc,(LPARAM)&lp);
}
void CEnumRsrcDlg::OnButton2()
{
CFileDialog fileOpen(TRUE,NULL,NULL,OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,NULL,this);
//过滤
fileOpen.m_ofn.lpstrFilter="exe\0*.exe\0dll\0*.dll\0All Files\0*.*\0\0";
if (fileOpen.DoModal()==IDOK)
{
SetDlgItemText(IDC_EDIT1,fileOpen.GetPathName());
}
}
效果图:
0 0
- EnumResourceNames枚举资源
- 枚举 51Nod1487 占领资源
- [Code Collection] 枚举LAN中的资源
- [VB]枚举 PE 文件里面的资源
- 用枚举构造完成资源绑定
- Windows PE资源表编程(枚举资源树)
- MSXML2.DOMDocument加载Internet资源时情况枚举[转载]
- MSXML2.DOMDocument加载Internet资源时情况枚举
- MSXML2.DOMDocument加载Internet资源时情况枚举
- 资源勘探 纪中1282 vijos 1663 枚举+分类讨论
- 51node 1487 占领资源【思维+暴力枚举】
- 枚举
- 枚举
- 枚举
- 枚举
- 枚举
- 枚举
- 枚举
- 《大型数据库作业2》客户端的配置与应用
- 实现简易的Struts.xml解析[内含反射的理解]
- mysql建立索引时中的length什么用
- 查询mysql中重复数据的方法
- Java解析Excel并把数据保存到数据库中
- EnumResourceNames枚举资源
- caffe学习笔记14-caffe可视化特征与权重
- linux cfs调度器_理论模型
- hiho一下 第140周-清理海报(DAG+dfs)
- IP头、TCP头、UDP头
- 问题总结一
- LeetCode 53. Maximum Subarray 题解
- scrapy框架拓展:为download_middleware添加用户代理池
- 协议 protocol