473,405 Members | 2,141 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

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 8197
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: John Fouhy | last post by:
Hi all, I have been attempting to change the title bar icon of my Tkinter applications in Windows XP. Chasing round in google, I discovered: - This is a common difficulty. - There aren't any...
17
by: Paul Rubin | last post by:
Dumb question from a Windows ignoramus: I find myself needing to write a Python app (call it myapp.py) that uses tkinter, which as it happens has to be used under (ugh) Windows. That's Windows...
7
by: Lalit | last post by:
Hi Friends, I have developed a Windows service. Now i need icon for this service in systray and context menu fo this icon. Can i do this? With regards, Lalit
5
by: Clyde | last post by:
I am trying to implement the user feedback provided by Windows Explorer when draggng a filename from one place to another. I have the drag and drop action worked out but have had no luck in...
4
by: Dan Sikorsky | last post by:
How do you set the this.Icon property of a windows form to the App.ico file specified in the Project Properties? I don't want to type in the path and filename; I want to set the form's icon...
11
by: **Developer** | last post by:
Need this: typedef struct _SHFILEINFO { HICON hIcon; int iIcon; DWORD dwAttributes; TCHAR szDisplayName; TCHAR szTypeName; } SHFILEINFO
4
by: tshad | last post by:
What would be a good way to check programmatically whether a service was running? We have a service that dies periodically and I need to check to see if this service is running. I know how to...
1
by: Jon Slaughter | last post by:
I'm trying to create a windows explorer like app and the problem I'm having is getting the proper icon for the folders and items. In windows explorer there are many different icons and most seem...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.