Hi, my question is: How can I extract an icon from my resource file and create an *.ico file from the data? I want to do this programmatically (Win32). Do you have a brief example?
On Jul 10, 8:56 am, "David" wrote: > Hi, my question is: > > How can I extract an icon from my resource file and create an *.ico file > from the data? > > I want to do this programmatically (Win32). Do you have a brief example? Hi, You can use the following APIs to extract icons from an executable file: ExtractAssociatedIcon() ExtractIcon() ExtractIconEx() PrivateExtractIcons() http://msdn.microsoft.com/en-us/library/ms648067(VS.85).aspx http://msdn.microsoft.com/en-us/library/ms648068(VS.85).aspx http://msdn.microsoft.com/en-us/library/ms648069(VS.85).aspx http://msdn.microsoft.com/en-us/library/ms648075(VS.85).aspx Kellie.
"David" wrote: > How can I extract an icon from my resource file and create an > *.ico file from the data? > > I want to do this programmatically (Win32). Do you have a brief > example? Actually, extracting an icon from an image is no different from extracting any ther resource. You need to: 1. Load an image that contains resources. 2. Enumerate resources. 3. If a resource does have an apropriate type (i.e., RT_ANIICON/RT_ICON), then you lock it and save the bits in a file with .ICO extension. That's all. Here's the example of updating a resource. Instead of updating you will need to save a resource. "Using Resources" http://msdn.microsoft.com/en-us/library/ms648008(VS.85).aspx HTH Alex
> 3. If a resource does have an apropriate type (i.e., > RT_ANIICON/RT_ICON), then you lock it and save the bits in a file > with .ICO extension. Good start. But just dumping the bits in a file don't result in a standard .ico file. You will have to use GROUP_ICON and ICON types and combine the bits yourself to get a real .ico file. Here is info on the formats: http://msdn.microsoft.com/en-us/library/ms997538.aspx http://msdn.microsoft.com/en-us/magazine/cc546571.aspx -- Mihai Nita [Microsoft MVP, Visual C++] http://www.mihai-nita.net ------------------------------------------ Replace _year_ with _ to get the real email
"Mihai N." wrote: > Good start. But just dumping the bits in a file don't result in > a standard .ico file. > > You will have to use GROUP_ICON and ICON types and combine the > bits yourself to get a real .ico file. Thanks for the correction. Alex