473,403 Members | 2,183 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

Extract exe file icon.

Hi
I want to extract icon of an exe file and want to know how.
I look at the MSDN and find out that I can use ExtractIconEx() Windows API
but in there are some changes to that api in c# I made those changes like
this :
public static extern uint ExtractIconEx(

[MarshalAs(UnmanagedType.LPTStr)]

string szFile,

int nIconIndex,

ref int[] phiconLarge,

ref int[] phiconSmall,

uint nIcons);

but its returns and integer array and not an icon.

I want to know did I do some thing wrong or I must do something further.

Anyway please tell me how I can do this

Thanks in advance

Mohammad-Reza
Nov 16 '05 #1
6 10478
Mohammed

You have to convert to icon using the following statement

Icon largeIcon1 = Icon.FromHandle(phiconLarge[0]);
Icon smallIcon1 = Icon.FromHandle(phiconSmall[0]);

--
Shak
C# .NET MCP
(Houston)


"Mohammad-Reza" <mr********@hotmail.com> wrote in message
news:#P**************@TK2MSFTNGP12.phx.gbl...
Hi
I want to extract icon of an exe file and want to know how.
I look at the MSDN and find out that I can use ExtractIconEx() Windows API
but in there are some changes to that api in c# I made those changes like
this :
public static extern uint ExtractIconEx(

[MarshalAs(UnmanagedType.LPTStr)]

string szFile,

int nIconIndex,

ref int[] phiconLarge,

ref int[] phiconSmall,

uint nIcons);

but its returns and integer array and not an icon.

I want to know did I do some thing wrong or I must do something further.

Anyway please tell me how I can do this

Thanks in advance

Mohammad-Reza

Nov 16 '05 #2
Thanks for your answer
In the api I must send pointer if an interger array to it
then I must use that array in the convert code or use phiconLarge or small
directly?

thanks.

"Shakir Hussain (C# .NET MCP)" <sh**@fakedomain.com> wrote in message
news:uj**************@tk2msftngp13.phx.gbl...
Mohammed

You have to convert to icon using the following statement

Icon largeIcon1 = Icon.FromHandle(phiconLarge[0]);
Icon smallIcon1 = Icon.FromHandle(phiconSmall[0]);

--
Shak
C# .NET MCP
(Houston)


"Mohammad-Reza" <mr********@hotmail.com> wrote in message
news:#P**************@TK2MSFTNGP12.phx.gbl...
Hi
I want to extract icon of an exe file and want to know how.
I look at the MSDN and find out that I can use ExtractIconEx() Windows API but in there are some changes to that api in c# I made those changes like this :
public static extern uint ExtractIconEx(

[MarshalAs(UnmanagedType.LPTStr)]

string szFile,

int nIconIndex,

ref int[] phiconLarge,

ref int[] phiconSmall,

uint nIcons);

but its returns and integer array and not an icon.

I want to know did I do some thing wrong or I must do something further.

Anyway please tell me how I can do this

Thanks in advance

Mohammad-Reza


Nov 16 '05 #3

After calling the ExtractIconEx api, do this

Icon largeIcon1 = Icon.FromHandle((IntPtr)phiconLarge[0]);

--
Shak
C# / .NET MCP
(Houston)
"Mohammad-Reza" <mr********@hotmail.com> wrote in message
news:eV**************@TK2MSFTNGP11.phx.gbl...
Thanks for your answer
In the api I must send pointer if an interger array to it
then I must use that array in the convert code or use phiconLarge or small
directly?

thanks.

"Shakir Hussain (C# .NET MCP)" <sh**@fakedomain.com> wrote in message
news:uj**************@tk2msftngp13.phx.gbl...
Mohammed

You have to convert to icon using the following statement

Icon largeIcon1 = Icon.FromHandle(phiconLarge[0]);
Icon smallIcon1 = Icon.FromHandle(phiconSmall[0]);

--
Shak
C# .NET MCP
(Houston)


"Mohammad-Reza" <mr********@hotmail.com> wrote in message
news:#P**************@TK2MSFTNGP12.phx.gbl...
Hi
I want to extract icon of an exe file and want to know how.
I look at the MSDN and find out that I can use ExtractIconEx() Windows API but in there are some changes to that api in c# I made those changes like this :
public static extern uint ExtractIconEx(

[MarshalAs(UnmanagedType.LPTStr)]

string szFile,

int nIconIndex,

ref int[] phiconLarge,

ref int[] phiconSmall,

uint nIcons);

but its returns and integer array and not an icon.

I want to know did I do some thing wrong or I must do something further.
Anyway please tell me how I can do this

Thanks in advance

Mohammad-Reza



Nov 16 '05 #4
This link might be of some help... :-)

http://www.pinvoke.net/default.aspx/....ExtractIconEx

--
HTH

Kyril Magnos
"I'm not a developer anymore, I'm a software engineer now!" :-)

"Mohammad-Reza" <mr********@hotmail.com> wrote in message
news:eV**************@TK2MSFTNGP11.phx.gbl...
| Thanks for your answer
| In the api I must send pointer if an interger array to it
| then I must use that array in the convert code or use phiconLarge or small
| directly?
|
| thanks.
|
| "Shakir Hussain (C# .NET MCP)" <sh**@fakedomain.com> wrote in message
| news:uj**************@tk2msftngp13.phx.gbl...
| > Mohammed
| >
| > You have to convert to icon using the following statement
| >
| > Icon largeIcon1 = Icon.FromHandle(phiconLarge[0]);
| > Icon smallIcon1 = Icon.FromHandle(phiconSmall[0]);
| >
| > --
| > Shak
| > C# .NET MCP
| > (Houston)
| >
| >
| >
| >
| > "Mohammad-Reza" <mr********@hotmail.com> wrote in message
| > news:#P**************@TK2MSFTNGP12.phx.gbl...
| > > Hi
| > > I want to extract icon of an exe file and want to know how.
| > > I look at the MSDN and find out that I can use ExtractIconEx() Windows
| API
| > > but in there are some changes to that api in c# I made those changes
| like
| > > this :
| > > public static extern uint ExtractIconEx(
| > >
| > > [MarshalAs(UnmanagedType.LPTStr)]
| > >
| > > string szFile,
| > >
| > > int nIconIndex,
| > >
| > > ref int[] phiconLarge,
| > >
| > > ref int[] phiconSmall,
| > >
| > > uint nIcons);
| > >
| > > but its returns and integer array and not an icon.
| > >
| > > I want to know did I do some thing wrong or I must do something
further.
| > >
| > > Anyway please tell me how I can do this
| > >
| > > Thanks in advance
| > >
| > > Mohammad-Reza
| > >
| > >
| >
| >
|
|
Nov 16 '05 #5
I try them but it doesn't work.
Would you please send me a sample code?
thanks

"Kyril Magnos" <ky**********@yahoo.com> wrote in message
news:#b**************@TK2MSFTNGP11.phx.gbl...
This link might be of some help... :-)

http://www.pinvoke.net/default.aspx/....ExtractIconEx

--
HTH

Kyril Magnos
"I'm not a developer anymore, I'm a software engineer now!" :-)

"Mohammad-Reza" <mr********@hotmail.com> wrote in message
news:eV**************@TK2MSFTNGP11.phx.gbl...
| Thanks for your answer
| In the api I must send pointer if an interger array to it
| then I must use that array in the convert code or use phiconLarge or small | directly?
|
| thanks.
|
| "Shakir Hussain (C# .NET MCP)" <sh**@fakedomain.com> wrote in message
| news:uj**************@tk2msftngp13.phx.gbl...
| > Mohammed
| >
| > You have to convert to icon using the following statement
| >
| > Icon largeIcon1 = Icon.FromHandle(phiconLarge[0]);
| > Icon smallIcon1 = Icon.FromHandle(phiconSmall[0]);
| >
| > --
| > Shak
| > C# .NET MCP
| > (Houston)
| >
| >
| >
| >
| > "Mohammad-Reza" <mr********@hotmail.com> wrote in message
| > news:#P**************@TK2MSFTNGP12.phx.gbl...
| > > Hi
| > > I want to extract icon of an exe file and want to know how.
| > > I look at the MSDN and find out that I can use ExtractIconEx() Windows | API
| > > but in there are some changes to that api in c# I made those changes | like
| > > this :
| > > public static extern uint ExtractIconEx(
| > >
| > > [MarshalAs(UnmanagedType.LPTStr)]
| > >
| > > string szFile,
| > >
| > > int nIconIndex,
| > >
| > > ref int[] phiconLarge,
| > >
| > > ref int[] phiconSmall,
| > >
| > > uint nIcons);
| > >
| > > but its returns and integer array and not an icon.
| > >
| > > I want to know did I do some thing wrong or I must do something
further.
| > >
| > > Anyway please tell me how I can do this
| > >
| > > Thanks in advance
| > >
| > > Mohammad-Reza
| > >
| > >
| >
| >
|
|

Nov 16 '05 #6
[DllImport("Shell32.dll",EntryPoint="ExtractIconExW ",CharSet=CharSet.Unicode,
ExactSpelling=true,CallingConvention=CallingConven tion.StdCall)]
public static extern int ExtractIconEx(string sFile,int iIndex, out IntPtr
piLargeVersion, out IntPtr piSmallVersion, int amountIcons);

public class Foo()
{
IntPtr large, small;
Icon extractedIcon;
ArrayList items;

public Foo()
{
items = new ArrayList();

// Extract Normal folder
ExtractIconEx("Shell32.dll", 3, out large,out small, 1);
extractedIcon= Icon.FromHandle(small);
items.Add(extractedIcon);

// Extract Open folder
ExtractIconEx("Shell32.dll", 4, out large,out small, 1);
extractedIcon= Icon.FromHandle(small);
items.Add(extractedIcon);

// Extract A drive
ExtractIconEx("Shell32.dll", 6, out large,out small, 1);
extractedIcon= Icon.FromHandle(small);
items.Add(extractedIcon);

// Extract Harddisk
ExtractIconEx("Shell32.dll", 8, out large,out small, 1);
extractedIcon= Icon.FromHandle(small);
items.Add(extractedIcon);

// Extract Network drive
ExtractIconEx("Shell32.dll", 9, out large,out small, 1);
extractedIcon= Icon.FromHandle(small);
items.Add(extractedIcon);

// Extract CDROM drive
ExtractIconEx("Shell32.dll", 11, out large,out small, 1);
extractedIcon= Icon.FromHandle(small);
items.Add(extractedIcon);
}
}

--
HTH

Kyril Magnos
"I'm not a developer anymore, I'm a software engineer now!" :-)

"Mohammad-Reza" <mr********@hotmail.com> wrote in message
news:Om**************@TK2MSFTNGP10.phx.gbl...
|I try them but it doesn't work.
| Would you please send me a sample code?
| thanks
|
| "Kyril Magnos" <ky**********@yahoo.com> wrote in message
| news:#b**************@TK2MSFTNGP11.phx.gbl...
| > This link might be of some help... :-)
| >
| > http://www.pinvoke.net/default.aspx/....ExtractIconEx
| >
| > --
| > HTH
| >
| > Kyril Magnos
| > "I'm not a developer anymore, I'm a software engineer now!" :-)
| >
| > "Mohammad-Reza" <mr********@hotmail.com> wrote in message
| > news:eV**************@TK2MSFTNGP11.phx.gbl...
| > | Thanks for your answer
| > | In the api I must send pointer if an interger array to it
| > | then I must use that array in the convert code or use phiconLarge or
| small
| > | directly?
| > |
| > | thanks.
| > |
| > | "Shakir Hussain (C# .NET MCP)" <sh**@fakedomain.com> wrote in message
| > | news:uj**************@tk2msftngp13.phx.gbl...
| > | > Mohammed
| > | >
| > | > You have to convert to icon using the following statement
| > | >
| > | > Icon largeIcon1 = Icon.FromHandle(phiconLarge[0]);
| > | > Icon smallIcon1 = Icon.FromHandle(phiconSmall[0]);
| > | >
| > | > --
| > | > Shak
| > | > C# .NET MCP
| > | > (Houston)
| > | >
| > | >
| > | >
| > | >
| > | > "Mohammad-Reza" <mr********@hotmail.com> wrote in message
| > | > news:#P**************@TK2MSFTNGP12.phx.gbl...
| > | > > Hi
| > | > > I want to extract icon of an exe file and want to know how.
| > | > > I look at the MSDN and find out that I can use ExtractIconEx()
| Windows
| > | API
| > | > > but in there are some changes to that api in c# I made those
| changes
| > | like
| > | > > this :
| > | > > public static extern uint ExtractIconEx(
| > | > >
| > | > > [MarshalAs(UnmanagedType.LPTStr)]
| > | > >
| > | > > string szFile,
| > | > >
| > | > > int nIconIndex,
| > | > >
| > | > > ref int[] phiconLarge,
| > | > >
| > | > > ref int[] phiconSmall,
| > | > >
| > | > > uint nIcons);
| > | > >
| > | > > but its returns and integer array and not an icon.
| > | > >
| > | > > I want to know did I do some thing wrong or I must do something
| > further.
| > | > >
| > | > > Anyway please tell me how I can do this
| > | > >
| > | > > Thanks in advance
| > | > >
| > | > > Mohammad-Reza
| > | > >
| > | > >
| > | >
| > | >
| > |
| > |
| >
| >
|
|
Nov 16 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Mehdi Mousavi | last post by:
Hi, I need to know how to extract a specific icon (32x32 for instance) from an icon file that contains more than one icon size? Any help would be highly appreciated, Cheers. Mehdi
2
by: Steve | last post by:
How can I extract a icon from a exist program? for examle, notepad.exe.
2
by: Dave | last post by:
Can anyone tell me how to extract the resources, specifically the description and icons, from a .EXE file programatically. Basically I want to write a C# application that takes .EXE files and...
3
by: VP Borza | last post by:
can anyone show me how can I extract icons from a dll or exe in visual basic ..net?
6
by: Udi | last post by:
Hi, I have an imagelist initialized in design time with several icons files (.ico). However, when I need to extract an icon (Image) from the Imagelist, I can't convert it back to an icon: ...
2
by: DG78 | last post by:
Hi, In VB 2005, How to extract icons (or images or other resources) from a file ..resx, .resource, .dll or .exe and then to create a new file with this resource (.ico, .jpg ..) ? Thanks ...
0
by: Frank | last post by:
If I have an icon file that contains one icon ExtractIconEx tells me there is one there. If the file contains 1 32x32 icon and one 16x16 icon ExtractIconEx still tells me there is one. I need...
7
by: =?Utf-8?B?QmVu?= | last post by:
Hi I am looking for a way to extraxt an icon from a .exe file an save it as an icon not a bitmap or jpeg to a file? The code below extracts the icon but only as a bitmap PictureBox1.Image =...
0
by: Sathyaish | last post by:
I want to get the icon from an IE shortcut (.url) file without passing a new WebRequest to the server. The .url is an INI file that has the path to the original URI where the icon file resides,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.