Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Windos
win32.3rdparty
win32.directx.audio
win32.directx.ddk
win32.directx.graphics
win32.directx.input
win32.directx.managed
win32.directx.misc
win32.directx.networking
win32.directx.sdk
win32.directx.video
win32.dirx.grap.shaders
win32.gdi
win32.international
win32.kernel
win32.messaging
win32.mmedia
win32.networks
win32.ole
win32.rtc
win32.tapi
win32.tapi.beta
win32.tools
win32.ui
win32.wince
win32.wmi
windows.mediacenter
winfx.aero
winfx.announcements
winfx.avalon
winfx.collaboration
winfx.fundamentals
winfx.general
winfx.indigo
winfx.sdk
winfx.winfs
  
 
date: Thu, 10 Jul 2008 17:56:46 +0200,    group: microsoft.public.win32.programmer.ui        back       


Extract icon from resource file   
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?
date: Thu, 10 Jul 2008 17:56:46 +0200   author:   David

Re: Extract icon from resource file   
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.
date: Thu, 10 Jul 2008 10:39:16 -0700 (PDT)   author:   Kellie Fitton

Re: Extract icon from resource file   
"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
date: Thu, 10 Jul 2008 20:48:54 +0300   author:   Alex Blekhman

Re: Extract icon from resource file   
> 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
date: Thu, 10 Jul 2008 22:19:15 -0700   author:   Mihai N.

Re: Extract icon from resource file   
"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
date: Fri, 11 Jul 2008 08:33:55 +0300   author:   Alex Blekhman

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us