Модераторы: Partizan, gambit
  

Поиск:

Ответ в темуСоздание новой темы Создание опроса
> Перезаписывание Icon в EXE, работа с ресурсами 
V
    Опции темы
Dino99rus
Дата 24.8.2008, 01:56 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Шустрый
*


Профиль
Группа: Участник
Сообщений: 83
Регистрация: 10.1.2007

Репутация: 1
Всего: 2



http://forum.vingrad.ru/forum/topic-103389.html
Суть такая, я разобрался как читать и писать ресурсы. Но не как не могу понять как правильно перезаписать Icon. Если писать в лоб то пишется просто набор байтов в файл ЕХЕ (типа того), сама винда не понимает что это и видет как просто файлы. Как я понял, чтобы записать Icon надо преобразовать файл *.ico  к правильной структуре, а потом только писать ее в ЕХЕ. Ничего подобного не нашел на с#, все под с++(т.к. я в с++ не так силен) разобраться тяжело. Как правильно записать *.ico в ЕХЕ?

PM MAIL   Вверх
nerezus
Дата 24.8.2008, 09:22 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Вселенский отказник
****


Профиль
Группа: Участник
Сообщений: 3330
Регистрация: 15.6.2005

Репутация: 1
Всего: 43



Цитата

Ничего подобного не нашел на с#, все под с++(т.к. я в с++ не так силен) разобраться тяжело. 
 Т.е. ты не можешь просто пример на C прочитать? о_О

Дай ссылки на эти мануалы - подскажем.


--------------------
Сообщество художников Artsociety.ru
PM MAIL WWW   Вверх
Dino99rus
Дата 24.8.2008, 17:29 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Шустрый
*


Профиль
Группа: Участник
Сообщений: 83
Регистрация: 10.1.2007

Репутация: 1
Всего: 2



http://www.rsdn.ru/Forum/?mid=2062075 - этот пример я еще не разбирал....

http://www.rsdn.ru/Forum/?mid=2062075 в этом примере как я понял сначала грузиться иконка из ехе, а потом сразу в другой ехе, а мне надо из файла ico.
http://www.codeguru.com/cpp/w-p/win32/tuto....php/c12873__2/ вот этот я пример взял как основу. 
Я уже понял что сначала перезаписывается RT_ICON сам файл, а потом RT_ICONS структура инфы   о иконке.

Вот пример моего переписывания этого кода под с#
Код

#pragma pack(push, 2)

typedef struct {
  WORD Reserved1;       // reserved, must be 0
  WORD ResourceType;    // type is 1 for icons
  WORD ImageCount;      // number of icons in structure (1)
  BYTE Width;           // icon width (32)
  BYTE Height;          // icon height (32)
  BYTE Colors;          // colors (0 means more than 8 bits per pixel)
  BYTE Reserved2;       // reserved, must be 0
  WORD Planes;          // color planes
  WORD BitsPerPixel;    // bit depth
  DWORD ImageSize;      // size of structure
  WORD ResourceID;      // resource ID
} GROUPICON;

#pragma pack(pop)

Код

[StructLayout(LayoutKind.Sequential, Pack = 1)]
    public struct GROUPICON
    {
        public int Reserved1;      
        public int ResourceType;    
        public int ImageCount;      
        public byte Width;           
        public byte Height;          
        public byte Colors;          
        public byte Reserved2;       
        public int Planes;          
        public int BitsPerPixel;    
        public long ImageSize;      
        public int ResourceID;      
    }

как я понял тип WORD и DWORD, это у нас, тип байт но большего размера чем тип BYTE

Код

void InjectMainIcon(char *Where, char *What)
{
   HANDLE hWhere = BeginUpdateResource(Where, FALSE);

   char *buffer;       // buffer to store raw icon data
   long buffersize;    // length of buffer
   int hFile;          // file handle

   hFile = open(What, O_RDONLY | O_BINARY);
   if (hFile == -1)
      return;          // if file doesn't exist, can't be opened etc.

   // calculate buffer length and load file into buffer
   buffersize = filelength(hFile);
   buffer     = (char *)malloc(buffersize);
   read(hFile, buffer, buffersize);
   close(hFile);

   UpdateResource(
      hWhere,                         // Handle to executable
      RT_ICON,                        // Resource type - icon
      MAKEINTRESOURCE(1),             // Make the id 1
      MAKELANGID(LANG_ENGLISH,        // Default language
                 SUBLANG_DEFAULT),
      (buffer+22),
      // skip the first 22 bytes because this is the  icon header
      // and directory entry (if the file  contains multiple
      // images, the directory entries will be larger than 22 bytes)
      buffersize-22    // length of buffer
     );

   // Again, we use this structure for educational purposes.
   // The icon header and directory entries can be read from the
   // file.
   GROUPICON grData;

   // This is the header
   grData.Reserved1 = 0;     // reserved, must be 0
   grData.ResourceType = 1;  // type is 1 for icons
   grData.ImageCount = 1;    // number of icons in structure (1)

   // This is the directory entry
   grData.Width        = 32;                 // icon width (32)
   grData.Height       = 32;                 // icon height (32)
   grData.Colors       = 0;                  // colors (256)
   grData.Reserved2    = 0;                  // reserved, must be 0
   grData.Planes       = 2;                  // color planes
   grData.BitsPerPixel = 32;                 // bit depth
   grData.ImageSize    = buffersize - 22;    // size of image
   grData.ResourceID   = 1;                  // resource ID is 1

   UpdateResource(
      hWhere,
      RT_GROUP_ICON,
      // RT_GROUP_ICON resources contain information about
      // stored icons
      "MAINICON",
      // MAINICON contains information about the application's
      // displayed icon
      MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT),
      &grData,
      // Pointer to this structure
      sizeof(GROUPICON)
     );


   free(buffer);    // free memory

   // Perform the update, don't discard changes
   EndUpdateResource(hWhere, FALSE);
}

 
Код

public static unsafe void InjectMainIcon(string Where, string What)
        {
            IntPtr hWhere = DllMethods.BeginUpdateResource(Where, false);
            
                BinaryReader hFile = new BinaryReader(File.OpenRead(What));
                long buffersizet = new FileInfo(What).Length;
                byte[] buffer = hFile.ReadBytes((int)buffersizet);
                hFile.Close();

                DllMethods.UpdateResource(hWhere, 3, 1, 0, buffer, (UInt32)buffersizet-22); 
           
                GROUPICON grData = new GROUPICON(); 
                
                grData.Reserved1 = 0;    
                grData.ResourceType = 1;  
                grData.ImageCount = 1;   
                // This is the directory entry
                grData.Width = 32;                 
                grData.Height = 32;                
                grData.Colors = 0;                  
                grData.Reserved2 = 0;                  
                grData.Planes = 2;                  
                grData.BitsPerPixel = 32;                
                grData.ImageSize = buffersizet-22; 
                grData.ResourceID = 1;  

                int len = sizeof(GROUPICON);
                byte[] buf = new byte[len];
                Marshal.Copy(new IntPtr(&grData), buf, 0, len);

                DllMethods.UpdateResource(hWhere, 14, 32512, 0, buf, (uint)len);   
                DllMethods.EndUpdateResource(hWhere, false);
        }


с RT_ICON разобрался как ее записать, осталось как правильно записать структуру в RT_ICONS



Это сообщение отредактировал(а) Dino99rus - 24.8.2008, 19:27
PM MAIL   Вверх
nerezus
Дата 26.8.2008, 13:35 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Вселенский отказник
****


Профиль
Группа: Участник
Сообщений: 3330
Регистрация: 15.6.2005

Репутация: 1
Всего: 43



Цитата

как я понял тип WORD и DWORD, это у нас, тип байт но большего размера чем тип BYTE
 В типах .NET WORD - это uint16, DWORD - это uint32


--------------------
Сообщество художников Artsociety.ru
PM MAIL WWW   Вверх
Dino99rus
Дата 27.8.2008, 16:48 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Шустрый
*


Профиль
Группа: Участник
Сообщений: 83
Регистрация: 10.1.2007

Репутация: 1
Всего: 2



пришлось пару деньков  smile 
вот что вышло
Код

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Security;
using Microsoft.Win32.SafeHandles;
using System.Globalization;
using System.IO;
using System.Collections;



namespace resEdit
{
    public partial class Form1 : Form
    {
        public Resource res = new Resource("e:\\qw\\PEFile.exe");
        public Resource upRes = new Resource();       
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            pictureBox1.Image = res.GetIconResourceAsImage(new IntPtr((uint)1));
            pictureBox2.Image = res.GetIconsResourceAsImage("#32512");
            DllMethods.EnumResourceNames(res.hModule,new IntPtr((uint) ResourceType.RT_ICON), new DllMethods.EnumResourceNameDelegate(EnumRes), IntPtr.Zero);
            DllMethods.FreeLibrary(res.hModule);
            upRes.ProcessCmdLine("e:\\qw\\PEFile.exe", "e:\\qw\\www.txt", "txt",1);            
            Load("e:\\qw\\qw3.ico");
            
        }

        public bool EnumRes(IntPtr hModule, IntPtr lpszType, IntPtr lpszName, IntPtr lParam)
        {
            Image img;
            img = res.GetIconResourceAsImage(lpszName);
            //img = res.GetIconsResourceAsImage(lpszName.ToString());
            img.Save("d:\\" + lpszName + ".ico");
            return true;
        }

        public void Load(string fileName)
        {
            FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read);
            try
            {
                Load(fs);
                fs.Close();
            }
            finally
            {
                if (fs != null)
                    fs.Close();
            }
        }
        public unsafe void Load(Stream stream)
        {
            ICONDIR ico = new ICONDIR();
            ICONDIRENTRY ico2 = new ICONDIRENTRY();
            byte[] array = new byte[sizeof(ICONDIR)];
            stream.Read(array, 0, sizeof(ICONDIR));
            fixed (byte* pData = array)
                ico = *(ICONDIR*)pData;            
            
            BinaryReader br = new BinaryReader(stream);
            byte[] array2 = new byte[sizeof(ICONDIRENTRY)];
            br.Read(array2, 0, sizeof(ICONDIRENTRY));
            fixed (byte* pData = array2)
                ico2 = *(ICONDIRENTRY*)pData;
            br.Close();
            InjectMainIcon("e:\\qw\\PEFile.exe", "e:\\qw\\qw3.ico", ico, ico2);
        }

        public unsafe static void InjectMainIcon(string Where, string What, ICONDIR ico,ICONDIRENTRY ico2)
        {            
            IntPtr hWhere = DllMethods.BeginUpdateResource(Where, false);
            BinaryReader hFile = new BinaryReader(File.OpenRead(What));
            uint buffersizet = (uint)new FileInfo(What).Length;
            byte[] buffer = hFile.ReadBytes((int)buffersizet);           
            hFile.Close();            
            byte[] buffer2 = new byte[buffersizet - 22];
            for (int i = 0; i < buffersizet - 22; i++)
            {
                buffer2[i]= buffer[i + 22];
            }
            DllMethods.UpdateResource(hWhere, 3, 1, 0, buffer2, (UInt32)buffersizet - 22);
            GROUPICON grData = new GROUPICON(); 
            // This is the header
            grData.idReserved = ico.idReserved;     
            grData.idType = ico.idType;  
            grData.idCount = ico.idCount;    
            // This is the directory entry
            grData.bWidth = ico2.bWidth;                 
            grData.bHeight = ico2.bHeight;                 
            grData.bColorCount = ico2.bColorCount;                  
            grData.bReserved = ico2.bReserved;                  
            grData.wPlanes = ico2.wPlanes;                  
            grData.wBitCount = ico2.wBitCount;
            grData.dwBytesInRes = buffersizet - 22; 
            grData.dwImageOffset = 1;

            DllMethods.UpdateResource(hWhere, 14, 32512, 0, &grData, sizeof(GROUPICON));
            DllMethods.EndUpdateResource(hWhere, false);
        }
    }
    
    
    #region structs
    public struct ICONDIRENTRY   // This is the Directory Entry stored in resources
    {
        public byte bWidth;
        public byte bHeight;
        public byte bColorCount;
        public byte bReserved;
        public ushort wPlanes;
        public ushort wBitCount;
        public uint dwBytesInRes;
        public uint dwImageOffset;
    }
 
    public struct ICONDIR   
    {
        public UInt16 idReserved;
        public UInt16 idType;
        public UInt16 idCount;    
    }
   
    [StructLayout(LayoutKind.Sequential, Pack = 2)]
    public struct GROUPICON
    {
        public UInt16 idReserved;      // reserved, must be 0
        public UInt16 idType;          // type is 1 for icons
        public UInt16 idCount;         // number of icons in structure (1)
        public byte bWidth;            // icon width (32)
        public byte bHeight;           // icon height (32)
        public byte bColorCount;       // colors (0 means more than 8 bits per pixel)
        public byte bReserved;         // reserved, must be 0
        public ushort wPlanes;         // color planes
        public ushort wBitCount;       // bit depth
        public uint dwBytesInRes;      // size of structure
        public uint dwImageOffset;     // resource ID
    } 
    #endregion


    public static class ExternDll
    {
        public const string Kernel32 = "kernel32.dll";
        public const string User32 = "user32.dll";
    }

    public unsafe  static class DllMethods
    {
        [DllImport(ExternDll.Kernel32, CharSet = CharSet.Unicode, ExactSpelling = true, EntryPoint = "LoadLibraryExW")]
        public static extern IntPtr LoadLibraryEx(string lpFileName, IntPtr hFile, uint dwFlags);

        [DllImport(ExternDll.Kernel32, ExactSpelling = true)]
        [return: MarshalAs(UnmanagedType.Bool)]
        public static extern bool FreeLibrary(IntPtr hModule);        

        [DllImport(ExternDll.Kernel32, CharSet = CharSet.Unicode, ExactSpelling = true, EntryPoint = "FindResourceExW")]
        public static extern IntPtr FindResourceEx(IntPtr hModule, IntPtr lpType, IntPtr lpId);        

        [DllImport(ExternDll.Kernel32, CharSet = CharSet.Auto, SetLastError = true)]
        public static extern IntPtr FindResource(IntPtr hModule,  IntPtr lpid,IntPtr lpType);        

        [DllImport(ExternDll.Kernel32, CharSet = CharSet.Unicode, SetLastError = true)]
        public static extern int SizeofResource(IntPtr hModule, IntPtr hResInfo);

        [DllImport(ExternDll.Kernel32, CharSet = CharSet.Unicode, ExactSpelling = true)]
        public static extern IntPtr LoadResource(IntPtr hModule, IntPtr hResInfo);

        [DllImport(ExternDll.User32, EntryPoint = "LoadImageW", CharSet = CharSet.Unicode, ExactSpelling = true)]
        public static extern IntPtr LoadImage(IntPtr hInst, string lpszName, uint uType, int cxDesired, int cyDesired, uint fuLoad);

        [DllImport(ExternDll.Kernel32, CharSet = CharSet.Unicode, ExactSpelling = true)]
        public static extern IntPtr LockResource(IntPtr hResInfo);
                
        
        [DllImport(ExternDll.Kernel32, EntryPoint = "EnumResourceTypesW", CharSet = CharSet.Unicode, SetLastError = true)]
        [return: MarshalAs(UnmanagedType.Bool)]
        public static extern bool EnumResourceTypes(IntPtr hModule, EnumResourceTypeDelegate lpEnumFunc, IntPtr lParam);

        [DllImport(ExternDll.Kernel32, EntryPoint = "EnumResourceNamesW", CharSet = CharSet.Unicode, SetLastError = true)]
        [return: MarshalAs(UnmanagedType.Bool)]
        public static extern bool EnumResourceNames(IntPtr hModule, IntPtr lpszType, EnumResourceNameDelegate lpEnumFunc, IntPtr lParam);

        public delegate bool EnumResourceNameDelegate(IntPtr hModule, IntPtr lpszType, IntPtr lpszName, IntPtr lParam);
        public delegate bool EnumResourceTypeDelegate(IntPtr hModule, IntPtr lpszType, IntPtr lParam);           

        [DllImport(ExternDll.User32, SetLastError = true)]
        public static extern IntPtr CreateIconFromResource(IntPtr presbits, int dwResSize, bool fIcon, uint dwVer);

        [DllImport(ExternDll.Kernel32, EntryPoint = "BeginUpdateResourceW", SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
        public static extern IntPtr BeginUpdateResource(string pFileName, bool bDeleteExistingResources);

        [DllImport(ExternDll.Kernel32, EntryPoint = "UpdateResourceW", SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
        public static extern bool UpdateResource(IntPtr hUpdate, UInt32 pType, UInt32 PName, UInt16 wLanguage, resEdit.GROUPICON* pData, int cbData);

        [DllImport(ExternDll.Kernel32, EntryPoint = "UpdateResourceW", SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
        public static extern bool UpdateResource(IntPtr hUpdate, string pType, UInt32 pName, UInt16 wLanguage, byte[] pData, UInt32 cbData);
        [DllImport(ExternDll.Kernel32, EntryPoint = "UpdateResourceW", SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
        public static extern bool UpdateResource(IntPtr hUpdate, UInt32 pType, UInt32 pName, UInt16 wLanguage, byte[] pData, UInt32 cbData);

        [DllImport(ExternDll.Kernel32, EntryPoint = "EndUpdateResourceW", SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
        public static extern bool EndUpdateResource(IntPtr hUpdate, bool bDiscard);
    }

    public enum ResourceType : uint
    {
        RT_ICON = 3,
        RT_ICONS = 14,        
    }
    

    public class Resource
    {
        public IntPtr hModule;
        private const uint DONT_RESOLVE_DLL_REFERENCES = 0x00000001;
        private const uint LOAD_LIBRARY_AS_DATAFILE = 0x00000002;

        public Resource(string filePathName)            
        {
            hModule = DllMethods.LoadLibraryEx(filePathName, IntPtr.Zero, DONT_RESOLVE_DLL_REFERENCES | LOAD_LIBRARY_AS_DATAFILE);        
        }
        private Hashtable table = new Hashtable(2);
        public Resource()
        {            
            table.Add("RT_ICON", ResourceType.RT_ICON);            
            table.Add("RT_ICONS", ResourceType.RT_ICONS);
        }

        public Image GetIconResourceAsImage(IntPtr iconId)
        {
            IntPtr result = IntPtr.Zero;
            result = GetIconFromResource(iconId);
            if (result != IntPtr.Zero)
                return Icon.FromHandle(result).ToBitmap();
            else
                return null;
        }

        private IntPtr GetIconFromResource(IntPtr id)
        {
            int size = 0;
            IntPtr result = IntPtr.Zero;
            if (TryLockResource(ResourceType.RT_ICON, id, ref size, out result))
                return DllMethods.CreateIconFromResource(result, size, true, 0x00030000);                      
            return result;
        }

        protected bool TryLockResource(ResourceType Type, IntPtr Name, ref int resourceSize, out IntPtr result)
        {        

            result = DllMethods.FindResource(hModule,Name, new IntPtr((uint)Type));            
             if (result == IntPtr.Zero)
                return false;
            IntPtr hResData = DllMethods.LoadResource(hModule, result);
            if (hResData == IntPtr.Zero)
                return false;
            resourceSize = DllMethods.SizeofResource(hModule, result);
            if (resourceSize == 0)
                return false;
            result = DllMethods.LockResource(hResData);
            return true;
        }

        public Image GetIconsResourceAsImage(string iconsId)
        {
            IntPtr result = IntPtr.Zero;
            result = GetImage(1, iconsId);
            if (result != IntPtr.Zero)
                return Icon.FromHandle(result).ToBitmap();
            else
                return null;            
        }

        private IntPtr GetImage(uint type, string id)
        {
            uint u = 0;
            if (uint.TryParse(id, out u))
                return DllMethods.LoadImage(hModule, "#" + id, type, 0, 0, 0x8000);
            return DllMethods.LoadImage(hModule, id, type, 0, 0, 0x8000);
        }        

        enum ResType
        {
            ResourceError = 0,    // ошибка при определении типа
            ResourceIsNumber = 1, // тип задан числовым идентификатором
            ResourceIsString = 2  // тип задан строкой
        };

        private ResType ResolveResource(string[] str, out uint nResType, out uint nResID)
        {
            nResType = 0;
            nResID = 0;
            
            try
            {
                nResID = Convert.ToUInt32(str[2]);
            }
            catch 
            {                
                return ResType.ResourceError;
            }
                        
            try
            {
                if (table.ContainsKey(str[1])) 
                {
                    nResType = Convert.ToUInt32(table[str[1]]);
                }
                else 
                    nResType = Convert.ToUInt32(str[1]);
            }
            catch (Exception)
            {                
                return ResType.ResourceIsString;
            }
            
            return ResType.ResourceIsNumber;
        }

        private void UpdateResource(IntPtr hUpdate, string strResFile, string strResType, uint nResID)
        {
            using (BinaryReader reader = new BinaryReader(File.OpenRead(strResFile)))
            {
                long nCount = new FileInfo(strResFile).Length;
                byte[] bytes = reader.ReadBytes((int)nCount);
                reader.Close();
                DllMethods.UpdateResource(hUpdate, strResType, nResID, 1049, bytes, (UInt32)nCount);                    
            }
        }
        private void UpdateResource(IntPtr hUpdate, string strResFile, uint nResType, uint nResID)
        {
            using (BinaryReader reader = new BinaryReader(File.OpenRead(strResFile)))
            {
                long nCount = new FileInfo(strResFile).Length;
                byte[] bytes = reader.ReadBytes((int)nCount);
                reader.Close();

                DllMethods.UpdateResource(hUpdate, nResType, nResID, 0, bytes, (UInt32)nCount);
                    
            }
        }
       
        private bool AppendResource(IntPtr hUpdate, string[] str)
        {
            try
            {
                uint nResType;
                uint nResID;
                
                ResType res = ResolveResource(str, out nResType, out nResID);
                if (res == ResType.ResourceError)
                    return false;
                else
                {
                    if (res == ResType.ResourceIsNumber)
                        UpdateResource(hUpdate, str[0], nResType, nResID);
                    else
                        UpdateResource(hUpdate, str[0], str[1], nResID);
                }
            }
            catch 
            {               
                return false;
            }
            return true;
        }
        
        private bool AppendResource(IntPtr hUpdate, string strResourceInfo)
        {
            string[] str = null;

            if (strResourceInfo.StartsWith("\""))
            {
                int nIndex = strResourceInfo.LastIndexOf("\"");
                if (nIndex <= 0 || nIndex >= strResourceInfo.Length)
                    return false;

                string strResName = strResourceInfo.Substring(0, nIndex + 1);
                strResName = strResName.Replace('\"', ' ').Trim();

                string strRest = strResourceInfo.Substring(nIndex + 2).Trim();

                string[] strsRest = strRest.Split(new char[] { ' ', '\t' });
                if (strsRest.Length != 2)
                    return false;

                str = new string[] { strResName, strsRest[0], strsRest[1] };
            }
            else
                str = strResourceInfo.Split(new char[] { ' ', '\t' });

            if (str == null || str.Length != 3)
                return false;

            return AppendResource(hUpdate, str);
        }

        public void ProcessCmdLine(string pFileName,string strResFile, string strResType, uint nResID)
        {
            try
            {
                IntPtr hUpdate = DllMethods.BeginUpdateResource(pFileName, false);
                if (hUpdate != IntPtr.Zero)
                {                
                    StringBuilder strb = new StringBuilder();
                    strb.AppendFormat("\"{0}\" {1} {2}", new object[] { strResFile, strResType, nResID });                    
                    DllMethods.EndUpdateResource(hUpdate, !AppendResource(hUpdate, strb.ToString()));
                }
            }
            catch 
            {
                return;
            }
        }
    }   
}


Код ужасенsmile, это просто мой черновой вариант. 
Тут показано как читать и писать иконки в ЕХЕ, а также находить ресурсы без знания их имен в ЕХЕ.
При записи в ЕХЕ иконки рассмотрен вариант что в формате иконке только один вид отображения, но их может быть и больше.
Надеюсь эта инфа быстро поможет разобраться с иконками и ресурсами.
PM MAIL   Вверх
  
Ответ в темуСоздание новой темы Создание опроса
Прежде чем создать тему, посмотрите сюда:
mr.DUDA
THandle

Используйте теги [code=csharp][/code] для подсветки кода. Используйтe чекбокс "транслит" если у Вас нет русских шрифтов.
Что делать если Вам помогли, но отблагодарить помощника плюсом в репутацию Вы не можете(не хватает сообщений)? Пишите сюда, или отправляйте репорт. Поставим :)
Так же не забывайте отмечать свой вопрос решенным, если он таковым является :)


Если Вам понравилась атмосфера форума, заходите к нам чаще! С уважением, mr.DUDA, THandle.

 
0 Пользователей читают эту тему (0 Гостей и 0 Скрытых Пользователей)
0 Пользователей:
« Предыдущая тема | Общие вопросы по .NET и C# | Следующая тема »


 




[ Время генерации скрипта: 0.0966 ]   [ Использовано запросов: 22 ]   [ GZIP включён ]


Реклама на сайте     Информационное спонсорство

 
По вопросам размещения рекламы пишите на vladimir(sobaka)vingrad.ru
Отказ от ответственности     Powered by Invision Power Board(R) 1.3 © 2003  IPS, Inc.