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

A

Alexander Keßler

Hi,

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?
 
D

Dennis Myrén

Unfortunately, I think you will need to use Win32 API for that.
In shell32.dll there is SHGetFileInfo.
 
J

Julijan Sribar

Alexander Keßler said:
Hi,

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?


Hello Alexander,

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.

HTH.

Regards,

Julijan
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top