473,554 Members | 2,855 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(Unman agedType.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 10498
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********@hot mail.com> wrote in message
news:#P******** ******@TK2MSFTN GP12.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(Unman agedType.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**@fakedomai n.com> wrote in message
news:uj******** ******@tk2msftn gp13.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********@hot mail.com> wrote in message
news:#P******** ******@TK2MSFTN GP12.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(Unman agedType.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)phicon Large[0]);

--
Shak
C# / .NET MCP
(Houston)
"Mohammad-Reza" <mr********@hot mail.com> wrote in message
news:eV******** ******@TK2MSFTN GP11.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**@fakedomai n.com> wrote in message
news:uj******** ******@tk2msftn gp13.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********@hot mail.com> wrote in message
news:#P******** ******@TK2MSFTN GP12.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(Unman agedType.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********@hot mail.com> wrote in message
news:eV******** ******@TK2MSFTN GP11.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**@fakedomai n.com> wrote in message
| news:uj******** ******@tk2msftn gp13.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********@hot mail.com> wrote in message
| > news:#P******** ******@TK2MSFTN GP12.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(Unman agedType.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**********@y ahoo.com> wrote in message
news:#b******** ******@TK2MSFTN GP11.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********@hot mail.com> wrote in message
news:eV******** ******@TK2MSFTN GP11.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**@fakedomai n.com> wrote in message
| news:uj******** ******@tk2msftn gp13.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********@hot mail.com> wrote in message
| > news:#P******** ******@TK2MSFTN GP12.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(Unman agedType.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("Shel l32.dll",EntryP oint="ExtractIc onExW",CharSet= CharSet.Unicode ,
ExactSpelling=t rue,CallingConv ention=CallingC onvention.StdCa ll)]
public static extern int ExtractIconEx(s tring 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(extra ctedIcon);

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

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

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

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

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

--
HTH

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

"Mohammad-Reza" <mr********@hot mail.com> wrote in message
news:Om******** ******@TK2MSFTN GP10.phx.gbl...
|I try them but it doesn't work.
| Would you please send me a sample code?
| thanks
|
| "Kyril Magnos" <ky**********@y ahoo.com> wrote in message
| news:#b******** ******@TK2MSFTN GP11.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********@hot mail.com> wrote in message
| > news:eV******** ******@TK2MSFTN GP11.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**@fakedomai n.com> wrote in message
| > | news:uj******** ******@tk2msftn gp13.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********@hot mail.com> wrote in message
| > | > news:#P******** ******@TK2MSFTN GP12.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(Unman agedType.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
8582
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
1487
by: Steve | last post by:
How can I extract a icon from a exist program? for examle, notepad.exe.
2
2022
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 displays their description and their icons, more or less like right-clicking the file in explorer and displaying properties. -- Dave
3
1476
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
10980
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: statusBarPanel1.Icon = imageList1.Images; // cast/as don't work // Cannot convert type 'System.Drawing.Image' to 'System.Drawing.Icon' What am I...
2
4628
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 Dominique
0
1372
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 to know how many icons of each size is in the file. I want to extract the icons as they exist in the file. That is, if there is a 17x17 and a...
7
2334
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 = Drawing.Icon.ExtractAssociatedIcon("file.exe").ToBitmap The problem is I need the icon not the bitmap.
0
2351
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, but I don't want to make a new web request. Surely the file must be somewhere already on the local system. Is there a way to get it?
0
7506
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7782
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7541
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7872
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6123
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3545
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3533
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2006
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1114
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.