Hi Ron,
Based on my understanding, you want to get all the registed file extensions
in Windows system, then you want to get the associated icons of these file
extension.
================================
Actually, all the registed file extensions are stored in registry. They are
stored as the sub keys of HKEY_CLASSES_ROOT key.
In C#, you may use Microsoft.Win32.RegistryKey to access the registry, then
loop through all the HKEY_CLASSES_ROOT's sub keys, that is started with
"."(such as .bmp, .avi etc)
I also want to inform you that, the icon is not associated with certain
file extension. Each file extension has default open program(For details,
it also associates with certain behavior). And the icon is associated with
the open program and behavior. So you should first find the default open
behavior of the file extension, then find the associated icon.
Take .mp3 file for example:
1). Use RegistryKey.GetValue to get the (Default) program behavior
associated with ".mp3" file extension.(On my machine, it is "Winamp.File")
2). Find "Winamp.File" sub key also in HKEY_CLASSES_ROOT key.
3). There should be a "DefaultIcon" sub key in "Winamp.File".
4). Then, also use RegistryKey.GetValue method to retrieve the associated
icon address(On my machine, it is "C:\Program Files\Winamp\Winamp.exe,1")
At last, you should P/invoke ExtractAssociatedIcon Win32 API to retrieve
the associated icon.
================================
Please apply my suggestion above and let me know if it helps resolve your
problem.
Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.
Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! -
www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.