473,614 Members | 2,351 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 10503
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
8587
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
1493
by: Steve | last post by:
How can I extract a icon from a exist program? for examle, notepad.exe.
2
2027
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
1480
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
10997
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 mising here?
2
4635
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
1374
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 22x22 icon in the file I want to extract
7
2340
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
2356
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
8197
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8142
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8589
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8287
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
7114
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6093
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4058
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
1757
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1438
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.