tags:

views:

84

answers:

2

I have started coding an FTP client application (for fun). I’m trying to represent remotely hosted files with icons. For example, let’s say I’m browsing the root folder of an FTP server (/) and want to display the Backup.zip file with the icon association from that client operating system. On some systems, this may be the windows compression icon and other operating systems this may be WinZip or WinRAR icons.

I have the client browsing local files with the SHGetFileInfo() function. This works great with files that are local, however, this function requires the physical file in order to retrieve the associated icon. So, this will not work with remotely hosted files. I have found some samples of loading icons given a file extension, and this is really where the question comes in... What would be the best strategy to get icons associated to remote files?

  1. Go to the registry every time and look up extension to icon associations
  2. Create 1 byte files with each extension and use the SHGetFileInfo() function for remote files (using local 1 byte files as association for remote files)
  3. Other strategies???

What would a professional software company creating an FTP client do?

Thank you for your time.

-Jessy Houle

+1  A: 

I suggest that you don't go to the registry every time: go if you need to, but if you've already been for a given filetype then remember/cache that result (within your program) and reuse it.

ChrisW
Registry access to HKCR will be sufficiently fast, as this part is very likely to be cached. I expect any remote file listing process to be orders of magnitude slower. However, caching the icons themselves should be worthwhile.
Tomalak
+1  A: 

Use the procedure here from a previous Stack Overflow question on the same idea and uses the registry instead of an actual file.

How can I get the filetype icon that Windows Explorer shows?

Jeff Cuscutis