How to get the Symbol/Icon associated with special directory or file

Discussion in 'Microsoft C# .NET' started by Alexander Keßler, Oct 15, 2004.

  1. Hi,
    I asked u this morning:

    ---------------------------------------
    I want to programm some kind of Explorer like the Windows Explorer.
    And I want to know how can i get the same Icons/Symbols for the files and
    directories like the Windows Explorer uses.

    Example:

    The Icon for the Desktop.

    With the Command:
    Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
    I can get the folder where the Windows Desktop is located.

    But how can I get the standart icon for the desktop?
    --------------------------------------

    U answerd me:

    ---------------------------------------
    You'll have to use WinApi's SHGetFileInfo method. Check these:

    http://support.microsoft.com/?kbid=319350

    http://www.codeguru.com/Csharp/Csharp/cs_misc/icons/article.php/c4261/

    Note that for retrieving icons for individual files, it is much faster to
    use filename extension since it will fetch icons from the shell icon cache.
    --------------------------------------

    This works fine, but, I don't get the right Icon for the Desktop. If I use
    the directory where the desktop is stored in, I get a simple Folder Icon.
    Not the nice blue Desktop Icon.

    Does s.o. know how to get that Icon? (And all the other special Icons)


    Thanx

    Alex
     
    Alexander Keßler, Oct 15, 2004
    #1
    1. Advertisements

  2. >
    > http://www.codeguru.com/Csharp/Csharp/cs_misc/icons/article.php/c4261/
    >
    > Note that for retrieving icons for individual files, it is much faster to
    > use filename extension since it will fetch icons from the shell icon
    > cache.
    > --------------------------------------
    >
    > This works fine, but, I don't get the right Icon for the Desktop. If I use
    > the directory where the desktop is stored in, I get a simple Folder Icon.
    > Not the nice blue Desktop Icon.
    >
    > Does s.o. know how to get that Icon? (And all the other special Icons)
    >


    Have you tried just getting the Icon for "Desktop"?

    I don't know if it'll work, but its worth a shot.
     
    Daniel O'Connell [C# MVP], Oct 16, 2004
    #2
    1. Advertisements

  3. "Daniel O'Connell [C# MVP]" <> schrieb im
    Newsbeitrag news:...
    > >
    >> http://www.codeguru.com/Csharp/Csharp/cs_misc/icons/article.php/c4261/
    >>
    >> Note that for retrieving icons for individual files, it is much faster to
    >> use filename extension since it will fetch icons from the shell icon
    >> cache.
    >> --------------------------------------
    >>
    >> This works fine, but, I don't get the right Icon for the Desktop. If I
    >> use the directory where the desktop is stored in, I get a simple Folder
    >> Icon. Not the nice blue Desktop Icon.
    >>
    >> Does s.o. know how to get that Icon? (And all the other special Icons)
    >>

    >
    > Have you tried just getting the Icon for "Desktop"?
    >
    > I don't know if it'll work, but its worth a shot.


    Yes I tried, but it doesn't work. Any other ideas?
     
    Alexander Keßler, Oct 16, 2004
    #3
  4. Alexander Keßler

    Joep Guest

    Not sure but have a look here: www.thedrebin.com

    It shows one way to extract ico stuff from shell32.dll.
     
    Joep, Oct 16, 2004
    #4
  5. Well..

    in this class the following statement is used:

    System.Drawing.Icon.ExtractAssociatedIcon(....)

    The ExtractAssociatedIcon method does not exist in the System.Drawing.Icon
    class.

    Does s.o. know how to fix?



    "Joep" <> schrieb im Newsbeitrag
    news:4170ecfe$0$14941$4all.nl...
    > Not sure but have a look here: www.thedrebin.com
    >
    > It shows one way to extract ico stuff from shell32.dll.
    >
    >
     
    Alexander Keßler, Oct 16, 2004
    #5
  6. Alexander Keßler

    Joep Guest

    Joep, Oct 16, 2004
    #6
  7. Uhhh wow.... they say:
    First seen in: .NET v1.2.30703

    The newest .Net version is 1.1, isn't it?

    Maybee, i look for that version.... :)



    "Joep" <> schrieb im Newsbeitrag
    news:41713ef4$0$78753$4all.nl...
    > What about?
    >
    > http://www.winfx247.com/247reference/system/drawing/icon/__member/ExtractAssociatedIcon
    >
    > Any good? Guess not, so then maybe use the win32 equivalent? That will
    > work for sure but requires a wrap, shell32.dll, ExtractAssociatedIcon.
    >
    >
    >
    >
    >
    >
    >
     
    Alexander Keßler, Oct 16, 2004
    #7
  8. Ohh... wow.. the newest .net Framework is 2.0 on microsoft.com :)

    I think this will solve many problems.

    So far, many thanks for your help.


    "Alexander Keßler" <> schrieb im Newsbeitrag
    news:cks0oa$scj$-kl.de...
    > Uhhh wow.... they say:
    > First seen in: .NET v1.2.30703
    >
    > The newest .Net version is 1.1, isn't it?
    >
    > Maybee, i look for that version.... :)
    >
    >
    >
    > "Joep" <> schrieb im Newsbeitrag
    > news:41713ef4$0$78753$4all.nl...
    >> What about?
    >>
    >> http://www.winfx247.com/247reference/system/drawing/icon/__member/ExtractAssociatedIcon
    >>
    >> Any good? Guess not, so then maybe use the win32 equivalent? That will
    >> work for sure but requires a wrap, shell32.dll, ExtractAssociatedIcon.
    >>
    >>
    >>
    >>
    >>
    >>
    >>

    >
    >
     
    Alexander Keßler, Oct 16, 2004
    #8
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Moses M
    Replies:
    6
    Views:
    705
    Willy Denoyette [MVP]
    Jun 25, 2004
  2. Alexander Keßler
    Replies:
    2
    Views:
    214
    Julijan Sribar
    Oct 15, 2004
  3. Chris Martinez via .NET 247
    Replies:
    0
    Views:
    669
    Chris Martinez via .NET 247
    Mar 11, 2005
  4. John

    Active directory users and associated groups

    John, Mar 14, 2005, in forum: Microsoft C# .NET
    Replies:
    2
    Views:
    177
  5. Visual Systems AB \(Martin Arvidsson\)

    How to get icon associated with a document.

    Visual Systems AB \(Martin Arvidsson\), Apr 28, 2005, in forum: Microsoft C# .NET
    Replies:
    1
    Views:
    166
Loading...

Share This Page