Getting file type name and/or icon from explorer

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Brian Henry

    Getting file type name and/or icon from explorer

    I want to list out a directory listing along with showing the file type name
    (like explorer does when it says something like "MyDoc.DOC - Microsoft Word
    Document" How do I get that file type name which is Microsoft Word Document
    based on the extension or what ever it needs to figure out the type so i can
    display it in a program? also is there a simple way to get the icon of the
    file type? I've seen complex ways before, but is there any simple ways to?
    thanks!


  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: Getting file type name and/or icon from explorer

    Brian,

    There is no simple way to get it as far as I know. What you need to do
    is call the SHGetFileInfo API function through the P/Invoke layer.
    Fortunately, the details of the declaration have already been handled for
    you on pinvoke.net. You can find the definition you need (and supporting
    structures) at (watch for line wrap):



    Hope this helps.


    --
    - Nicholas Paldino [.NET/C# MVP]
    - mvp@spam.guard. caspershouse.co m

    "Brian Henry" <nospam@nospam. com> wrote in message
    news:ueluKTjgFH A.2268@TK2MSFTN GP15.phx.gbl...[color=blue]
    >I want to list out a directory listing along with showing the file type
    >name (like explorer does when it says something like "MyDoc.DOC - Microsoft
    >Word Document" How do I get that file type name which is Microsoft Word
    >Document based on the extension or what ever it needs to figure out the
    >type so i can display it in a program? also is there a simple way to get
    >the icon of the file type? I've seen complex ways before, but is there any
    >simple ways to? thanks!
    >[/color]


    Comment

    • Herfried K. Wagner [MVP]

      #3
      Re: Getting file type name and/or icon from explorer

      Brian,

      "Brian Henry" <nospam@nospam. com> schrieb:[color=blue]
      >I want to list out a directory listing along with showing the file type
      >name (like explorer does when it says something like "MyDoc.DOC - Microsoft
      >Word Document" How do I get that file type name which is Microsoft Word
      >Document based on the extension or what ever it needs to figure out the
      >type so i can display it in a program? also is there a simple way to get
      >the icon of the file type? I've seen complex ways before, but is there any
      >simple ways to?[/color]

      The .NET Framework does not provide managed support to determine file type
      descriptions and icons.

      Determining the description of a file's file type
      <URL:http://dotnet.mvps.org/dotnet/faqs/?id=getfiledesc ription&lang=en >

      Getting File Icons Using The Shell
      <URL:http://vbaccelerator.c om/article.asp?id= 4302>

      --
      M S Herfried K. Wagner
      M V P <URL:http://dotnet.mvps.org/>
      V B <URL:http://classicvb.org/petition/>

      Comment

      Working...