Results 1 to 6 of 6

Thread: [2.0] Reading Icons within C#

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2000
    Location
    Cairo, Egypt
    Posts
    126

    [2.0] Reading Icons within C#

    How could I read the application icon and extract it from another application to use it as icon or any other image format or drawing it in a picture box within the calling application. If there could I read a specific size for the icon or read all and use one size into another tool. I mean could I read all the sizes of the icon and can I use them separately in my application?

  2. #2
    Hyperactive Member drattansingh's Avatar
    Join Date
    Sep 2005
    Posts
    395

    Re: [2.0] Reading Icons within C#

    Why would you need to read the icon from another application?

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Dec 2000
    Location
    Cairo, Egypt
    Posts
    126

    Re: [2.0] Reading Icons within C#

    I'd like to make an application to run another applications by callig them with shell and I want to make it dynamic to have the shortcuts for the other applications with thier icons to be clearly to the users, so the number and the application itself I don't know and they can modify at any time so I need to read the applications icons to show to the user to select from.

  4. #4
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367

    Re: [2.0] Reading Icons within C#

    If you just want to get the icon, you can use the ExtractAssociatedIcon method:

    Code:
                System.Drawing.Icon oIcon = System.Drawing.Icon.ExtractAssociatedIcon(@"C:\Program files\Microsoft Office\Office12\winword.exe");
                button1.Image = oIcon.ToBitmap();
    
                oIcon = System.Drawing.Icon.ExtractAssociatedIcon(@"C:\Windows\system32\calc.exe");
                button2.Image = oIcon.ToBitmap();

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Dec 2000
    Location
    Cairo, Egypt
    Posts
    126

    Re: [2.0] Reading Icons within C#

    Thanks Negative it works but is there any other way to read a specific size for the Icon like 16X16, 23X23... etc. I tried your sample and it reads the size 32X32 only.

  6. #6
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367

    Re: [2.0] Reading Icons within C#

    You could try this code from the Codebank, I haven't looked at it, but it appears to use the API:

    http://www.vbforums.com/showthread.php?t=330985

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width