NULL

解决方案 »

  1.   

    把可执行文件以二进制流形式打开,再存为另一个文件。当然,这个新文件的图标你可以按下面的步骤进行定制!1.先注册你的文件扩展名如(*.123)
     ::RegCreateKey(HKEY_CLASSES_ROOT, ".123", &hKey);
     ::RegSetValue(hKey, NULL, REG_SZ, "My123App",strlen(...));
    2.再注册123file键
     ::RegCreateKey(HKEY_CLASSES_ROOT, "123file", &hKey);
    3.建立一个子键(DefaultIcon),设置其默认的字符串值
     ::RegCreateKey(HKEY_CLASSES_ROOT, "DefaultIcon", hKey)
     ::RegSetValue(hKey, NULL, REG_SZ, "c:\my123app.exe -150",strlen(...)); 
     将my123app.exe图标资源中的标号为150的RT_GROUP_ICON作为*.123文件的图标
      

  2.   

    代码实现如下://读取各种资源内部图标并显示在左侧列表框中void CIconSnapDlg::OnOK() {    CFileDialog fileDialog( TRUE,"*.ICO",NULL,NULL,"资源文件(*.ICO,*.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+ "文件载入错误,必须是WIN32的文件!", "错误", MB_OK );         return;        }        // Store the info        EDII.szFileName =szOpenFileName;        EDII.hInstance = hLibrary;            // Fill in the listbox with the icons available        if( ! EnumResourceNames( EDII.hInstance, RT_GROUP_ICON, (ENUMRESNAMEPROC )MyEnumProcedure, (LPARAM)GetSafeHwnd()) )        {         MessageBox( "列举图标资源名时出错!", "错误", MB_OK );         return;        }     }      m_List.SetCurSel (0);     if( m_List.GetCount()  == 0 )     {         MessageBox( "此文件中没有图标资源!", "错误", MB_OK );         //无图标资源,置保存和复制按钮为无效状态         m_Copy.EnableWindow (false);         m_SaveAs.EnableWindow (false);         return;     }        //有图标资源,置保存和复制按钮为有效状态     m_Copy.EnableWindow (true);     m_SaveAs.EnableWindow (true);      //刷新调用OnPaint来显示图标     InvalidateRect(NULL,TRUE);}   }在OnPaint()涵数中加入下面代码用来具体显示提取出的图标或位图资源。//根据左侧图标列表,利用OnPaint()来更新右侧相应图标LPTSTR lpIconID;HICON hIcon;if((lpIconID=(LPTSTR)m_List.GetItemData(m_List.GetCurSel()))!=(LPTSTR)LB_ERR ){ if(szOpenFileExtName=="exe"||szOpenFileExtName=="dll"||szOpenFileExtName=="icl") {       hIcon=pIcons->GetIconFromInstance(EDII.hInstance,lpIconID);   CStatic* pStatic = (CStatic*) GetDlgItem(IDC_ICONS);   pStatic->SetIcon (hIcon); }}2、如何将提取出的图标资源保存为Ico或Bmp格式。//保存图标资源为ICO或BMP格式文件void CIconSnapDlg::OnButtonSaveas() {    LPTSTR lpIconID;     CFileDialog fileDialog( FALSE,"*.ICO",NULL,NULL,"图标文件(*.ICO)|*.ICO|位图文件(*.BMP)|*.BMP||");    if (fileDialog.DoModal() == IDOK)     {        szSaveFileName=fileDialog.GetPathName();            szSaveFileExtName= fileDialog.GetFileExt ();        szSaveFileExtName.MakeLower ();         if(szOpenFileExtName=="exe"||szOpenFileExtName=="dll"||szOpenFileExtName=="icl")           if((lpIconID=(LPTSTR)m_List.GetItemData (m_List.GetCurSel()))!= (LPTSTR)LB_ERR)                lpIR=pIcons->ReadIconFromEXEFile (szOpenFileName,lpIconID);        if(szSaveFileExtName=="bmp")        {          if(lpIR!=NULL && m_List.GetCount ()>0)          {            BeginWaitCursor();            pIcons->IconImageToBMPFile (szSaveFileName,&lpIR->IconImages [0]);            EndWaitCursor();          }          else            MessageBox( "没有可保存的图标资源!", "错误", MB_OK );        }        else if(szSaveFileExtName=="ico")        {          if(lpIR!=NULL && m_List.GetCount ()>0)          {            BeginWaitCursor();            pIcons->WriteIconToICOFile (lpIR,szSaveFileName);            EndWaitCursor();          }          else            MessageBox( "没有可保存的图标资源!", "错误", MB_OK );        }    }}
      

  3.   

    楼上兄台,我是想要一个改exe文件图标的程序,而不是得到exe文件图标的程序。
      

  4.   

    我现在只有该程序的exe文件,而没有源代码。
      

  5.   

    用VC打开这个.exe程序,选择按资源方式打开,找到这个其丑无比的图标,然后画一个更难看的,保存一下~~~:)
      

  6.   

    can VC open the file:*.exe?
      

  7.   

    但是无法更新这个exe文件啊,把里面的资源读出来另存为,但就是改不了啊.
      

  8.   

    用VC打开可执行文件修改里面的资源需要在 win2000操作系统下才能保存。
      

  9.   

    上面打错字了,是需要win2000操作系统下才能修改并且保存。