473,748 Members | 5,230 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Get Associated icons for a file extension

I want to be able to get the icon associated with a certain file extension.

I can read the registry hkey_classes to get the ext. then look to the other
key for default icon.

How can I then extract the icon in file x at index 1 or whatever?

Again, I am not dealing with a file exactly but with a string path of the
file that has an extension.

I want to be able to take .pdf and get it's icon just by know .pdf, or .exe
or whatever.

Thanks,

Shane
Nov 20 '05 #1
7 8073
On 2003-12-12, Shane Story <Th*******@TAKE OUTTHISSPAMBUST ERsofthome.net> wrote:
I want to be able to get the icon associated with a certain file extension.

I can read the registry hkey_classes to get the ext. then look to the other
key for default icon.

How can I then extract the icon in file x at index 1 or whatever?

Again, I am not dealing with a file exactly but with a string path of the
file that has an extension.

I want to be able to take .pdf and get it's icon just by know .pdf, or .exe
or whatever.

Thanks,

Shane


ExtractIcon or ExtractIconEx come to mind.

--
Tom Shelton
MVP [Visual Basic]
Nov 20 '05 #2
On 2003-12-12, Shane Story <Th*******@TAKE OUTTHISSPAMBUST ERsofthome.net> wrote:
I want to be able to get the icon associated with a certain file extension.

I can read the registry hkey_classes to get the ext. then look to the other
key for default icon.

How can I then extract the icon in file x at index 1 or whatever?

Again, I am not dealing with a file exactly but with a string path of the
file that has an extension.

I want to be able to take .pdf and get it's icon just by know .pdf, or .exe
or whatever.

Thanks,

Shane

Better yet - just remembered...

ExtractAssocita tedIcon

--
Tom Shelton
MVP [Visual Basic]
Nov 20 '05 #3
Shane,
I want to be able to get the icon associated with a certain file extension.


HOW TO: Use the SHGetFileInfo Function to Get the Icons That Are
Associated with Files in Visual Basic .NET
http://support.microsoft.com/?kbid=319340

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 20 '05 #4
On 2003-12-12, Mattias Sjögren <ma************ ********@mvps.o rg> wrote:
Shane,
I want to be able to get the icon associated with a certain file extension.


HOW TO: Use the SHGetFileInfo Function to Get the Icons That Are
Associated with Files in Visual Basic .NET
http://support.microsoft.com/?kbid=319340

Mattias


Dang! I didn't know that one....

--
Tom Shelton
MVP [Visual Basic]
Nov 20 '05 #5
Dang ?,

Forgive me and no offense meant, but you sound like a 1930's gold prospector
from the frozen Yukon wastelands

' dag nabbit! '

;-)

Regards - OHM#


Tom Shelton wrote:
On 2003-12-12, Mattias Sjögren <ma************ ********@mvps.o rg>
wrote:
Shane,
I want to be able to get the icon associated with a certain file
extension.


HOW TO: Use the SHGetFileInfo Function to Get the Icons That Are
Associated with Files in Visual Basic .NET
http://support.microsoft.com/?kbid=319340

Mattias


Dang! I didn't know that one....


Regards - OHM# On**********@BT Internet.com
Nov 20 '05 #6
Dang! I didn't know that one....


I'm not sure it's worth knowing about, the code isn't very good
anyway. Doesn't compile with Option Strict On, and the SHFILEINFO
struct is incorrect (missing the StructLayout attribute for auto
charset).

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 20 '05 #7
for anyone looking, the answer to this is found in an article on 1-14-04
between SStory and Ken Tucker
entitled... !Help with API call from vb. Must be trampling memory or
something!

The answer is to take Ken's class and use the flags that were in my original
function to get it just via exesion.

ie. for a .exe file pass ".exe" and get the right icon.

Shane
"Shane Story" <Th*******@TAKE OUTTHISSPAMBUST ERsofthome.net> wrote in message
news:Or******** ******@TK2MSFTN GP11.phx.gbl...
I want to be able to get the icon associated with a certain file extension.
I can read the registry hkey_classes to get the ext. then look to the other key for default icon.

How can I then extract the icon in file x at index 1 or whatever?

Again, I am not dealing with a file exactly but with a string path of the
file that has an extension.

I want to be able to take .pdf and get it's icon just by know .pdf, or ..exe or whatever.

Thanks,

Shane

Nov 20 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1902
by: andrea.gavana | last post by:
Hello NG, I have searched everyweher, and I am not able to find a solution... basically, I am constructing a GUI with wxPython, in which I have a list. In this list control, I have some file. I would like to associate (to every file) its icon (on Windows). I have searched about the use of Mark Hammond's win32all extensions and also ctypes, but I didn't find a solution. Could anyone please provide a very simple example on how to retrieve...
1
1724
by: moquet.laurence | last post by:
In the registry, File extension's icons are stored like this : filename,resource_number. How can I extract the specific resource number from this file (using .Net framework)?
2
2165
by: Matthias S. | last post by:
Hi, I need to find the Icons associated with a given file extension. I guess there are registry entries for that. Is there a generic way of getting them? Thanks a lot in advance, Matthias
2
2012
by: Alexander Keßler | last post by:
Hi, I want to programm some kind of Explorer like the Windows Explorer. And I want to know how can i get the same Icons/Symbols for the files and directories like the Windows Explorer uses. Example: The Icon for the Desktop.
7
7324
by: Alexander Keßler | last post by:
Hi, I asked u this morning: --------------------------------------- I want to programm some kind of Explorer like the Windows Explorer. And I want to know how can i get the same Icons/Symbols for the files and directories like the Windows Explorer uses. Example:
1
15092
by: Víctor | last post by:
I'm doing a kind of file explorer with some additional funcionalities. The problem is that I'm not able to draw file extension icons in a ListView. I know how obtain icons, but when I try to draw file icon, this isn't showed. I tried to do by two ways: 1- By creating the ListViewItem and adding it to ListView, then I get rectangle of icon element and paint a new icon in rectangle coordenates. I'm able to view icons while they are...
1
1340
by: Progalex | last post by:
Hi guys.. How can I obtain the associated icon for each file extension registered on my machine via Visual Basic 2005 code? Many thanks.. Alessandro
4
3830
by: techspirit | last post by:
Hi all, 1) I found out from the vb.net group that it is possible to get an associated icon for a file. My requirement is to display all programs from the Start Menu for the user along with the associated icons. While I am able to list the programs correctly, the icons that get displayed alongside are the ones for the folders. The form has listview and imagelist controls on it. I shall paste the code here. 2) I was also wondering why...
1
1394
by: gevald123 | last post by:
I'm storing system files in a sql server database, as "image" datatype fields. In my front end (vb .net 1.1) I'd like to display these files in a listview with the "Windows Explorer" feel and look. I'm strugling to retreive the apropriate icon for the file extension, so far all the code I saw, it seems like that I have to pass a file name that exists in Windows O/S system file, in my case I'm not dealing with files strored in the O/S,...
0
8991
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8830
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
9544
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
9324
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
9247
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
6074
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();...
0
4606
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3313
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
3
2215
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.