469,609 Members | 1,166 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,609 developers. It's quick & easy.

Get Windows file type icon.

I already found that I have to use SHGetFileInfo to get the System's
associated icon with that file. But what about I just want to get
associated icon for some specific extensions? For example, 'avi'.

Think of a P2P program. The user searched for 'avi', and the program
should show result avi files with associated icons but there's no
actual file on the users system. Maybe a workaround is to create a dumb
(0KB) temp.avi file somewhere on the users system, and then apply
SHGetFileInfo. I know that would work but looks crappy. Please teach me
a decent method. Thank you.

Jul 18 '06 #1
4 8039
Use: Icon.ExtractAssociatedIcon
--
-Demetri
"Sin Jeong-hun" wrote:
I already found that I have to use SHGetFileInfo to get the System's
associated icon with that file. But what about I just want to get
associated icon for some specific extensions? For example, 'avi'.

Think of a P2P program. The user searched for 'avi', and the program
should show result avi files with associated icons but there's no
actual file on the users system. Maybe a workaround is to create a dumb
(0KB) temp.avi file somewhere on the users system, and then apply
SHGetFileInfo. I know that would work but looks crappy. Please teach me
a decent method. Thank you.

Jul 18 '06 #2
Demetri,

This won't work because it will not allow the caller to get the icon for
a particular extension without having a file which has that extension.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Demetri" <De*****@discussions.microsoft.comwrote in message
news:81**********************************@microsof t.com...
Use: Icon.ExtractAssociatedIcon
--
-Demetri
"Sin Jeong-hun" wrote:
>I already found that I have to use SHGetFileInfo to get the System's
associated icon with that file. But what about I just want to get
associated icon for some specific extensions? For example, 'avi'.

Think of a P2P program. The user searched for 'avi', and the program
should show result avi files with associated icons but there's no
actual file on the users system. Maybe a workaround is to create a dumb
(0KB) temp.avi file somewhere on the users system, and then apply
SHGetFileInfo. I know that would work but looks crappy. Please teach me
a decent method. Thank you.


Jul 18 '06 #3
Jeong-hun,

From the documentation for SHGetFileInfo:

If the uFlags parameter includes the SHGFI_USEFILEATTRIBUTES flag, this
parameter does not have to be a valid file name. The function will proceed
as if the file exists with the specified name and with the file attributes
passed in the dwFileAttributes parameter. This allows you to obtain
information about a file type by passing just the extension for pszPath and
passing FILE_ATTRIBUTE_NORMAL in dwFileAttributes.

So basically, pass "*.avi" to the function, along with
FILE_ATTRIBUTE_NORMAL for the dwFileAttributes parameter, and it will look
up the icon for an avi file.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Sin Jeong-hun" <ty*******@gmail.comwrote in message
news:11**********************@p79g2000cwp.googlegr oups.com...
>I already found that I have to use SHGetFileInfo to get the System's
associated icon with that file. But what about I just want to get
associated icon for some specific extensions? For example, 'avi'.

Think of a P2P program. The user searched for 'avi', and the program
should show result avi files with associated icons but there's no
actual file on the users system. Maybe a workaround is to create a dumb
(0KB) temp.avi file somewhere on the users system, and then apply
SHGetFileInfo. I know that would work but looks crappy. Please teach me
a decent method. Thank you.

Jul 18 '06 #4
My bad, I thought he was talking about a file he already has.

--
-Demetri
"Nicholas Paldino [.NET/C# MVP]" wrote:
Demetri,

This won't work because it will not allow the caller to get the icon for
a particular extension without having a file which has that extension.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Demetri" <De*****@discussions.microsoft.comwrote in message
news:81**********************************@microsof t.com...
Use: Icon.ExtractAssociatedIcon
--
-Demetri
"Sin Jeong-hun" wrote:
I already found that I have to use SHGetFileInfo to get the System's
associated icon with that file. But what about I just want to get
associated icon for some specific extensions? For example, 'avi'.

Think of a P2P program. The user searched for 'avi', and the program
should show result avi files with associated icons but there's no
actual file on the users system. Maybe a workaround is to create a dumb
(0KB) temp.avi file somewhere on the users system, and then apply
SHGetFileInfo. I know that would work but looks crappy. Please teach me
a decent method. Thank you.



Jul 18 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by John Fouhy | last post: by
17 posts views Thread by Paul Rubin | last post: by
5 posts views Thread by Clyde | last post: by
4 posts views Thread by Dan Sikorsky | last post: by
11 posts views Thread by **Developer** | last post: by
4 posts views Thread by tshad | last post: by
1 post views Thread by Jon Slaughter | last post: by
reply views Thread by devrayhaan | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.