CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 12 of 12
  1. #1
    Join Date
    Jul 2008
    Posts
    18

    How to get MyComputer Icon?

    How can i get system icons like: MyComputer, MyDocuments, Desktop, ...

    I know how to do it for folders and file extensions but not for icons like mycomputer


    Thanks

  2. #2
    Join Date
    Aug 2008
    Posts
    112

    Re: How to get MyComputer Icon?

    Quote Originally Posted by sn4k3 View Post
    How can i get system icons like: MyComputer, MyDocuments, Desktop, ...

    I know how to do it for folders and file extensions but not for icons like mycomputer


    Thanks
    Icons on desktop are defined in shell32.dll
    And they are numbered increasingly,
    So you can view them first then
    Pick the right one of your flavor.
    hi,,,

  3. #3
    Join Date
    Jul 2008
    Posts
    18

    Re: How to get MyComputer Icon?

    Quote Originally Posted by Khiem View Post
    Icons on desktop are defined in shell32.dll
    And they are numbered increasingly,
    So you can view them first then
    Pick the right one of your flavor.
    any sample over there?
    i just need get the 'Icon' from icon

  4. #4
    Join Date
    Aug 2008
    Posts
    112

    Re: How to get MyComputer Icon?

    i remember if i am not mistaken that it may be ExtractIconFromFile of Image class...uh oh you need to check it out again or search google for a complete source code as you wish to obtain. :blink:
    hi,,,

  5. #5
    Join Date
    Jul 2008
    Posts
    18

    Re: How to get MyComputer Icon?

    Quote Originally Posted by Khiem View Post
    i remember if i am not mistaken that it may be ExtractIconFromFile of Image class...uh oh you need to check it out again or search google for a complete source code as you wish to obtain. :blink:
    think not, since MyComputer not have a path, also i want to get MyDocuments Folder icon, mycomputer and desktop icon (with current custom theme icons)

  6. #6
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,284

    Re: How to get MyComputer Icon?

    ExtractIconFromFile will only work with exe files ( at least to my knowledge )
    You are right with needing API though.

    You need the following to achieve what you want :

    API
    SHGetFileInfo

    Structure
    SHFILEINFO

    Constants
    SHGFI_ICON
    SHGFI_SMALLICON
    SHGFI_LARGEICON

    I did something similar in VB.NET ( unfortunately ), here's the link :
    http://www.codeguru.com/forum/showthread.php?t=417770

    It should give you an idea of what is needed.

    I hope my advice was helpful.

  7. #7
    Join Date
    Jul 2008
    Posts
    18

    Re: How to get MyComputer Icon?

    Quote Originally Posted by HanneSThEGreaT View Post
    ExtractIconFromFile will only work with exe files ( at least to my knowledge )
    You are right with needing API though.

    You need the following to achieve what you want :

    API
    SHGetFileInfo

    Structure
    SHFILEINFO

    Constants
    SHGFI_ICON
    SHGFI_SMALLICON
    SHGFI_LARGEICON

    I did something similar in VB.NET ( unfortunately ), here's the link :
    http://www.codeguru.com/forum/showthread.php?t=417770

    It should give you an idea of what is needed.

    I hope my advice was helpful.
    i already have that and working, but this only works for File and folders

    i want to get MyComputer icon wich not have an path and i need Desktop etc...

    icons from: SpecialFolders

  8. #8
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,284

    Re: How to get MyComputer Icon?

    Ah, it seems like I need glasses.

    You want the My Computer Icon, My Documents etc.

    I've got bad news for you, but, perhaps with a little good news - time will tell

    The whole problem is, that the My Computer object is merely an object, not really a fixed thing like a file ( if you get what I'm saying ). The only way that you would get this icon ( alongwith Network Places etc. ) will be to digg very deep into the Registry. Inside the Registry you'd need to find each object's CLSID, then use ExtractIcon, DrawIcon etc. APIs to extract it, and draw it onto something.

    If you don't know what CLSID is, here's an article about it - as you can relate in the article, I did extensive research on these objects :
    http://www.codeguru.com/vb/gen/vb_sy...php/c13987__1/

    That is the only solution.

  9. #9
    Join Date
    Jul 2008
    Posts
    18

    Re: How to get MyComputer Icon?

    Quote Originally Posted by HanneSThEGreaT View Post
    Ah, it seems like I need glasses.

    You want the My Computer Icon, My Documents etc.

    I've got bad news for you, but, perhaps with a little good news - time will tell

    The whole problem is, that the My Computer object is merely an object, not really a fixed thing like a file ( if you get what I'm saying ). The only way that you would get this icon ( alongwith Network Places etc. ) will be to digg very deep into the Registry. Inside the Registry you'd need to find each object's CLSID, then use ExtractIcon, DrawIcon etc. APIs to extract it, and draw it onto something.

    If you don't know what CLSID is, here's an article about it - as you can relate in the article, I did extensive research on these objects :
    http://www.codeguru.com/vb/gen/vb_sy...php/c13987__1/

    That is the only solution.
    yes it works, but it return Original icon, currently i have vista icons on my XP Theme and it return original XP theme icons now can i get the current theme icons?

  10. #10
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,284

    Re: How to get MyComputer Icon?

    Good, we're making progress
    You first have to determine if a theme is active, then perhaps further investigate the source of the icon

    To determine if a theme is Active, you need to use the IsAppThemed API inside UxTheme.dll.

    My article ( here ) goes into more details about using UxTheme.dll, I hope it helps!

  11. #11
    Join Date
    Jul 2008
    Posts
    18

    Re: How to get MyComputer Icon?

    Quote Originally Posted by HanneSThEGreaT View Post
    Good, we're making progress
    You first have to determine if a theme is active, then perhaps further investigate the source of the icon

    To determine if a theme is Active, you need to use the IsAppThemed API inside UxTheme.dll.

    My article ( here ) goes into more details about using UxTheme.dll, I hope it helps!
    yes and how can i extract the icon from theme?
    how others programs do? like filezilla or winrar ...

    probaly should exist a easy way to do that

  12. #12
    Join Date
    Jul 2008
    Posts
    18

    Re: How to get MyComputer Icon?


Tags for this Thread

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

Featured