We need you!

We're working hard on the next version of Developer Fusion. Let us know what you think we should be up to!

Members

Technology Zones

Articles

Hosted By

MaximumASP

Info

Rated
Read 48,508 times

Contents

Related Categories

File Extensions: Finding the default Icon - Drawing the Icon

couling

Drawing the Icon

So we now have the location of the default icon. There is just one problem with this, the icon may be stored in a .exe, .dll or .ico file. This is not as much of a problem as it may sound using the other group of three APIs that we declared at the beginning.

But we just need to do one thing first. The default icon it stored in the form of: “C:\BlahBlah\Blah.ico, 42”. We just need to split the number up from the location


    'Find the comma
    intN = InStrRev(strDefaultIcon, ",")
    'We MUST have an icon number and it will be after the ",": NO COMMA NO DEFAULT ICON
    If intN < 1 Then GoTo No_Icon
    'What number is after the comma
    lngIconNumber = Trim$(Right(strDefaultIcon, Len(strDefaultIcon) - intN))
    'We only want whatever is before the comma in the file name
    strDefaultIcon = Trim$(Left(strDefaultIcon, intN - 1))

So now we just need to do is draw the thing. This is where we need the “Device Context” (hDC) of our picture box:

Draw_Icon:
    'Extract the Icon
    lngIcon = ExtractIcon(App.hInstance, strDefaultIcon, lngIconNumber)
    'if 1 or 0 then after all that the Icon could not be retrieved
    If lngIcon = 1 Or lngIcon = 0 Then GoTo No_Icon
    lngError = DrawIcon(Picture_hDC, 0, 0, lngIcon) 'Draw the icon in the box
    'If that was unsucessful then we can't do anything about it now!
    lngError = DestroyIcon(lngIcon)
    'Again we can't correct any errors now
    Exit Sub

Just graduated from the University of Birmingham. Computer Science and Artifical Intelligence 2.2 Languages: Java c++ PHP Prolog VB6

Comments

  • Re: [2982] File Extensions: Finding the default Icon

    Posted by Anishsane on 22 May 2007

    does any one want to extract image used for icon?
    the icon may be in an exe file or dll file.
    this is a veryyyyyyyy long way, and there are ready softwares available for it.

    but it is dis...

  • About lessons and codes

    Posted by PATHFINDER on 16 Jul 2005

    I'll never be thankful enough to have decided to join Developer Fusion. It's real fun to have what's needed to start with programming language. I am really amazed of the progresses i have done in two ...

  • INTERESTING

    Posted by Tochukwu on 02 Jun 2005

    THAT WAS A NICE JOB.

    I AM AN UNDERGRADUATE STUDYING COMPUTER PRORAMMING. i WILL NEED MORE EXPLANATION ON THIS TOPIC.

    tOCHUKWU.

  • Posted by jab on 18 Sep 2003

    Absolutely brilliant! Works a treat.

    THANKS VERY MUCH!!!

  • Posted by couling on 13 Sep 2003

    Looks like my reply is too large to fit in one post so I've put it [url="http://mysite.freeserve.com/visualbasic/16.htm"]here[/url].

    Hope this helps :cool: