473,769 Members | 7,320 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 8215
Use: Icon.ExtractAss ociatedIcon
--
-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.co m

"Demetri" <De*****@discus sions.microsoft .comwrote in message
news:81******** *************** ***********@mic rosoft.com...
Use: Icon.ExtractAss ociatedIcon
--
-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
SHGetFileInf o. 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_USEFILEAT TRIBUTES 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 dwFileAttribute s parameter. This allows you to obtain
information about a file type by passing just the extension for pszPath and
passing FILE_ATTRIBUTE_ NORMAL in dwFileAttribute s.

So basically, pass "*.avi" to the function, along with
FILE_ATTRIBUTE_ NORMAL for the dwFileAttribute s parameter, and it will look
up the icon for an avi file.

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

"Sin Jeong-hun" <ty*******@gmai l.comwrote in message
news:11******** **************@ p79g2000cwp.goo glegroups.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.co m

"Demetri" <De*****@discus sions.microsoft .comwrote in message
news:81******** *************** ***********@mic rosoft.com...
Use: Icon.ExtractAss ociatedIcon
--
-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
2102
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 good answers. Eventually, I stumbled across a link to this: http://www.tcl.tk/man/tcl8.4/TkCmd/wm.htm#M18
17
3875
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 XP if it makes any difference. I put a shortcut to myapp.py on the desktop and it shows up as a little green snake icon, which is really cool and Pythonic. When I double click the icon, the app launches just fine and the tkinter interface does...
7
10332
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
4968
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 finding how to capture the piece of the screen into a bitmap to simulate the movement. I know this could be done with the Windows API but can't find any way to do it with .Net functions. Any help is appreciated.
4
23838
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 programmatically in the Form Load section. -- Thank you kindly, Dan Sikorsky MSCS, BSCE, BAB
11
3477
by: **Developer** | last post by:
Need this: typedef struct _SHFILEINFO { HICON hIcon; int iIcon; DWORD dwAttributes; TCHAR szDisplayName; TCHAR szTypeName; } SHFILEINFO
4
4182
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 check to see if the status is in stopped or running mode. But that doesn't tell me if it is actually running. I need to know this so that if it happens I can programmatically start the same service on another machine.
1
5100
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 to be in the shell32.dll. The problem is that there also seems to be custom icons that are installed by applications. For example, "My Music" In My Documents has an icon that is different from the normal folders. I have installed an application...
0
9423
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10216
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9997
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9865
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8873
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7413
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3965
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3565
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.