作者:徐景周
下载示例源码(/uploadfile/201210/15/49202412331.BMP,*.EXE,*.DLL,*.ICL)|*.ICO;*.BMP;*.EXE;*.DLL;*.ICL||");
if (fileDialog.DoModal() == IDOK)
{
szOpenFileName=fileDialog.GetPathName();
szOpenFileExtName= fileDialog.GetFileExt ();
szOpenFileExtName.MakeLower ();
m_List.ResetContent (); //选清空左侧图标列表框
//读取并显示ICON文件
if(szOpenFileExtName =="ico")
{
lpIR=pIcons->ReadIconFromICOFile (szOpenFileName);
HICON hIcon;
hIcon=ExtractIcon(AfxGetInstanceHandle(),szOpenFileName,0);
if(hIcon!=NULL)
m_List.AddString (szOpenFileName);
CStatic* pStatic = (CStatic*) GetDlgItem(IDC_ICONS);
pStatic->SetIcon (hIcon);
}
else if(szOpenFileExtName == "bmp") //读取并显示BMP文件
{
pIcons->IconImageFromBMPFile (szOpenFileName,&lpIR->IconImages[0],TRUE);
HICON hIcon;
hIcon=pIcons->MakeIconFromResource (&lpIR->IconImages [0]);
if(hIcon!=NULL)
m_List.AddString (szOpenFileName);
CStatic* pStatic = (CStatic*) GetDlgItem(IDC_ICONS);
pStatic->SetIcon (hIcon);
}
else //读取并显示EXE、DLL等资源文件
{
HINSTANCE hLibrary;
// Load the DLL/EXE - NOTE: must be a 32bit EXE/DLL for this to work
if( (hLibrary = LoadLibraryEx( szOpenFileName, NULL, LOAD_LIBRARY_AS_DATAFILE )) == NULL )
{
// Failed to load - abort
MessageBox( szOpenFileName+ "文件