Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Window icon changes with change in file extension

2 views
Skip to first unread message

Neelu

unread,
Oct 19, 2006, 1:51:07 AM10/19/06
to
when we change the extension of a file in windows, its icon also
changes.....
how does windows do tht.
in my application i require a similar approach. i want the icon to be
dependent on the file extension not on the attributes of the file.
i have gone trough the registry but things are not very clear. Windows

has listed all the file extensions avaliable there, but there is no
general way to extract icons for those extension...
kindly help

[Jongware]

unread,
Oct 19, 2006, 4:57:06 AM10/19/06
to

"Neelu" <neme...@gmail.com> wrote in message
news:1161237067....@e3g2000cwe.googlegroups.com...

A random extension in the registry, HKEY_CLASSES_ROOT: ".ftt". Contains
nothing but the Default key "FFTFile". The key "FFTFile" has a subkey
"DefaultIcon", and that contains "misc.exe,6" (the 6th icon in misc.exe,
whatever that is -- well, it IS a random example). Use ExtractIcon to, err,
extract this icon, if you really want to.
But there is no need to do this manually! The function ExtractAssociatedIcon
does *precisely* what the shell does (!). From MSDN:

"HICON ExtractAssociatedIcon(HINSTANCE hInst, LPTSTR lpIconPath, LPWORD
lpiIcon );
[...]
lpIconPath: Pointer to a string that specifies the full path and file name
of the file that contains the icon. The function extracts the icon handle
from that file, or from an executable file associated with that file. If the
icon handle is obtained from an executable file, the function stores the
full path and file name of that executable in the string pointed to by
lpIconPath."

Long URL warning: here comes a long URL.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/resources/icons/iconreference/iconfunctions/extractassociatedicon.asp

[Jongware]


Michael

unread,
Oct 19, 2006, 2:04:23 PM10/19/06
to
> > in my application i require a similar approach. i want the icon to be
> > dependent on the file extension not on the attributes of the file.
> > i have gone trough the registry but things are not very clear. Windows
> > has listed all the file extensions avaliable there, but there is no
> > general way to extract icons for those extension...

Check out SHGetFileInfo.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/functions/shgetfileinfo.asp

Michael

Message has been deleted

r_z_...@pen_fact.com

unread,
Oct 23, 2006, 4:05:49 PM10/23/06
to

I can't help you actually extract the icons. I can help a bit if
you're trying to change the icon that _Windows_ displays as a user
wanders around in Explorer. For that, you need to change the "File
Associations". So I used google to look up
file associations
in this newsgroup and got 78 hits. I didn't find anything wonderfully
helpful, but I only looked quickly. A 25 January 2001 contribution by
Jackson Yee to a thread called "File Associations" provided a sketch.

-----------------------------------------
To reply to me, remove the underscores (_) from my email address (and please indicate which newsgroup and message).

Robert E. Zaret, eMVP
PenFact, Inc.
20 Park Plaza, Suite 478
Boston, MA 02116
www.penfact.com

0 new messages