473,701 Members | 2,976 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

getting file icon

hi, how can i get the icon associated with a certain file type? thanks
Sep 21 '06 #1
1 2427
I had this document, it should help you.

How many times have you created your own application and wondered,
"Gee, this thing creates data files--how can I associate my data file
with my application, so that when a user double-click on the data file,
my application starts up and runs it?"

Well, you probably didn't think quite like that, but if you use Word,
you know that if you double-click on a "*.doc" file, Word opens up and
*poof* there's your document.

So how do you do that with VB.NET?

There are two ways, the easy way and the hard way. The easy way is best
because if your application gets uninstalled, so will your file
associations. But, you might have occasion to need the hard way. I'll
cover the hard way in a later faq.

Walk Through
The easy way

1. Open up your solution in Visual Studio. If you don't have Visual
Studio, I guess you're out of luck and have to use the hard way.

If you haven't already, add a Setup Project to your solution by File,
Add Project, New Project, Setup & Deployment Projects, Setup Project.

2. Right-click on your setup project in the "Solution Explorer" window,
select "View", then select "File Types".

You'll see the "File Types" window displayed in Visual Studio. At the
top of the window will be "File Types on Target Machine".

3. Right-click on "File Types on Target Machine". The menu will pop up
with "Add File Type" Click on this.

You will see "New Document Type #1" added, with "&Open" underneath it.

4. The "New Document Type #1" can be anything you want--change it to
something descriptive. Although the user never sees this, never use
something common--be as unique as possible, because you can overlay
current file associations without even realizing it. For example, you
might think "pngfile" might be a useful name--but using that will now
send all "*.png" files to your application, instead of to an image
viewer. A good practice may be to use "YourCompanyNam e.FileType", where
"YourCompanyNam e" is your name or your company's name, and "FileType"
is a descriptive text of your file.

5. In the "Properties " window for your new type, you will need to
change a few properties:

command: Change to the application you want to run. If you click
on the "...", you will be given your choices, and you will probably
want to locate and use the "Primary Output ..." file.
Description: This is what will show up when your file type is
seen in Windows Explorer.
Extensions: This is your list of extensions to associate with
this file type. You can list any number of extensions, just separate
with a comma, and you don't need to use a period. Avoid, at all costs,
using a common extension (such as ".doc"), because you will overwrite
any pre-existing types!
Icon: This will associate an icon with your file type, that
shows up in Windows Explorer.

6. Are we there yet? Almost--now we move on to that "&Open". This is an
action that is available if your right-click on the file. The default
action ("&Open" is currently set as the default) is what happens when
you double-click on the file. Right-click on your "New Document Type
#1" to add actions, but for the moment, lets define our "&Open" action.
Click on "&Open". You will see in the Properties window "Name",
"Arguments" , "Verb". Verb is hidden from the user, but is the key that
is stored in the registry. Leave it the same as the name, but without
the "&". The default for "Arguments" is "%1", which means to pass the
full path and filename to your application. You can add other stuff
here as well, if you need to pass flags to your application to do
special stuff. All this information is getting passed to your
application on the command line, so you'll need to be familiar with the
"Environment.Co mmandLine" object.
If you need to set a different action as your default, just
right-click on the action and select "Set as Default"

And that's it. Now, when you build your setup project, the file
associations will be included, so that when a user installs your
application, the associations will be installed as well, and if
(hopefully never) the user uninstalls your application, then the
associations will be removed.

Sep 21 '06 #2

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

Similar topics

by: Kendall Gifford | last post by:
Greetings. While trying to get a simple app working, I've been forced to delve into embedded and/or linked resources a bit. I read all the reference for the System.Resources namespace as well as all the material within the "Resources and Localization..." tutorial. While I'm confident I now know completely how to accomplish my original, simple task of embedding some icons into my assembly and use of the same at runtime, I realize I've a...
by: Brian Henry | last post by:
I want to list out a directory listing along with showing the file type name (like explorer does when it says something like "MyDoc.DOC - Microsoft Word Document" How do I get that file type name which is Microsoft Word Document based on the extension or what ever it needs to figure out the type so i can display it in a program? also is there a simple way to get the icon of the file type? I've seen complex ways before, but is there any...
by: Brian Henry | last post by:
How would you get the associated icon for the file type of a file with a certain extension? like BMP, JPEG, MPEG, etc etc find their default icon using the File Types listing that associates the extension with an icon in windows. thanks!
by: Brian Henry | last post by:
I have icons which contain 16x16, 24x24, and 32x32 icons in the single file and it is embedded as a resource... I need to get a 16x16 icon only out of it, how would i go about doing that? ive tried this Dim ico As Drawing.Icon = New Drawing.Icon(GetType(bdbGeneral).Assembly.GetManifestResourceStream("bdb.plugin.ico")) Dim icoMyIcon As Drawing.Icon = New Drawing.Icon(ico, SystemInformation.SmallIconSize)
by: IcingDeath via DotNetMonster.com | last post by:
I am building this SQL Server database app in which i can store files. In order to display files I want to have the app show the associated icon for the extension of the file that is in the database. Therefore the file doesnt really exist on the user's hard drive. All the file extracting techniques require that I have the actual file on the drive in order to get an icon for it. There is a workaround for this: i could create dummy files with...
by: farseer | last post by:
Hi, I created a new resouce ("app.resx") in my project and added an icon to this resource with name "IL_ICON". I would like to use this resource in some unmanaged code, in particular, with the api function SHNotificationAdd. How can i do this? i have tried using ResourceManager to get that icon, but i am getting back NULL. Even if i did get back an icon, how can i use this to with the hIcon parameter of SHNotificationAdd? thank you...
by: louismanukonda | last post by:
I'm newbie to xml I have an xml grammer file contain image files, i have to display the contents with an xsl file. The issue is when i mouseover the images i need to display the corresponding images from that xml file which i'm not able to get. I'm giving piece of code of xml and xsl files.Could u please tell me how can I get that work done
by: Tom | last post by:
I have a main VB.NET application that loads another VB.NET DLL dynamically. Once I have done that, I would like to be able to 'get' the icon of a form in that dynamically loaded DLL. How would one go about doing this in the main form, once the DLL has been loaded? Thanks in advance. Tom --
by: UJ | last post by:
I have an icon file stored as part of a program as a resource (Embedded Resource). How can I get the file out of the resource to be able to set a window's icon to the icon? (I know the icon is there because I can pull it out as bit map and display it.) TIA - Jeff.
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...
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,...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
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...
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();...
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...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
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.