Extract Icon

B

Ben

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.
Thanks
 
G

Gillard

Dim x As Integer = 1
'img is an imagelist
For Each ico As Image In img.Images
x = x + 1
pb1.Image = ico
Application.DoEvents()
ico.Save(apath & "icones\" & IO.Path.GetFileName(fil) & x &
".ico", System.Drawing.Imaging.ImageFormat.Icon)
Next
 
B

Ben

Hi Gillard

I know your code can work. but for some reason it is not working for me.
I added an imagelist
But what is "apath"
What is "fil"

When I ran your code, i used "c:\mydir" for "apath" and the path for
winword for "fil", I get a new page icon instead of the winword icon in the
folder.

Also for me to get anything at all I first had to run code to put the icon
into the imagelist and the picturebox
Here is the code I used to put the icon into the image list:

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button4.Click
Dim ico As Icon = Icon.ExtractAssociatedIcon(the path for
"winword.exe")
ImageList1.ImageSize = New Size(24, 24)
ImageList1.Images.Add(ico)

Dim theGraphics As Graphics = Graphics.FromHwnd(Me.Handle)

For count = 0 To ImageList1.Images.Count - 1

ImageList1.Draw(theGraphics, New Point(24, 24), count)

' Call Application.DoEvents to force a repaint of the form.
Application.DoEvents()

' Call the Sleep method to allow the user to see the image.
System.Threading.Thread.Sleep(1000)
Next

I am sorry, but I think I need a some more help on this...please
 
B

Ben

Hi there
Sorry to say, but for some reason I still have not seen the attachment, and
it is something I really need to take a look at.
I think it maybe bacause I was using IE 8.2 Beta. I am back to using IE 7.0
now. So, I am asking that you resend the attachment one last time for me
please.
Thanks
 
E

eBob.com

I wonder if some news servers do not allow attachments for this group? I
saw at least one of the earlier attachments. I use news.microsoft.com for
this newsgroup. It's free - so if that's not the server you use to see this
newsgroup I recommend that you try it.

Bob
 
G

Gillard

Use a news reader exemple Windows Live Mail
protocol NNTP
port : 119
server: msnews.microsoft.com
the attachment is there
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top