Page 1 of 1

File Associations In Visual Studio create your own .something files Rate Topic: ***** 1 Votes

#1 Rickster0  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 16
  • View blog
  • Posts: 236
  • Joined: 08-July 08

Posted 19 July 2008 - 06:04 AM

Ok i bet all of you at some time have asked yourself how do i get something like a .nxm and when i double click it my Program runs?

i will show you how to do it in 7 easy steps.

If you don't have visual studio then this won't help you.

Requirements
Visual Studio

1)Open up your solution in Visual studio.

2)Add a Setup Project to your solution by file , add project,New project, Setup & Deployment projects,Setup project

3)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"

4)Right-click on "File types on target machine".the menu will pop up with Add "file type" Click on this.

you'll see "New document Type#1" added,and "&open"underneath it.

5)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 maybe "YourCompantName.Filetype",where your company name is your name of your company's name, and "Filetype" is a descriptive text of your file.

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

Command:Change to the application that you want to run.If you click on the "..." and you will proberly want to locate and use the "primary Output..." File
Description: This is the description of the file type(if it doesn't describe it's self"
Extensions:This your list of extensions for you chosen Program.Separate each one with a ","
Icon:This will associate the icon with your file type,This shows up in the window explorer.

7)Nearly done...
Now we move 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","Verbs". Verb is hidden from the user,but is the key that is stored in the registry.Leave it 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 infomaton is getting passed to your application on the command line,so you'll need to be familiar with the "Environment.CommandLine" object.
If you need to set a different action as your default,just right click on the action and "set as default"

Hope this help everybody who's Pm me about it. biggrin.gif

Is This A Good Question/Topic? 2
  • +

Replies To: File Associations In Visual Studio

#2 Rickster0  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 16
  • View blog
  • Posts: 236
  • Joined: 08-July 08

Posted 20 July 2008 - 01:58 AM

I hope this helps alot of people

:P
Was This Post Helpful? 0
  • +
  • -

#3 Trickster090  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 41
  • Joined: 02-June 08

Posted 20 July 2008 - 02:09 AM

Thanks i've been searching for something like this for ages
Was This Post Helpful? 0
  • +
  • -

#4 born2c0de  Icon User is offline

  • printf("I'm a %XR",195936478);
  • member icon

Reputation: 180
  • View blog
  • Posts: 4,667
  • Joined: 26-November 04

Posted 20 July 2008 - 11:01 AM

:^:
Nice work.
Was This Post Helpful? 0
  • +
  • -

#5 Rickster0  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 16
  • View blog
  • Posts: 236
  • Joined: 08-July 08

Posted 24 July 2008 - 11:01 AM

ty ^_^
Was This Post Helpful? 0
  • +
  • -

#6 gbertoli3  Icon User is offline

  • DIC at Heart + Code
  • member icon

Reputation: 40
  • View blog
  • Posts: 1,162
  • Joined: 23-June 08

Posted 31 July 2008 - 04:26 PM

Great Post!
Was This Post Helpful? 0
  • +
  • -

#7 Rickster0  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 16
  • View blog
  • Posts: 236
  • Joined: 08-July 08

Posted 07 August 2008 - 04:40 AM

thanks again......looks like i've done something good.... lol :P
Was This Post Helpful? 0
  • +
  • -

#8 Guest_DaveCS*


Reputation:

Posted 17 May 2010 - 07:46 PM

Thank You very much for taking the time to write this great article.

MSDN was quite cryptic, this did the job great.

Thanks again.
Was This Post Helpful? 0

#9 SheenLim  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 28-February 11

Posted 28 February 2011 - 04:39 PM

I have created a installer and followed your instruction for file association..
but when I double click the file associate, nothing happends..

my code in my application is already expecting a argument.
But when I open my program it seems okay, why does my program do not run, even when I choose my main.exe to associate with this file?

http://cid-8aad94340...association.bmp

if (args.length == 0)
Application.Run(new FrmMain());

else
Application.Run(new FrmMain(args[0]));

This post has been edited by SheenLim: 28 February 2011 - 04:41 PM

Was This Post Helpful? 0
  • +
  • -

#10 Starry Guy  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 04-July 11

Posted 04 July 2011 - 12:47 PM

Thanks, this was very useful. Can I just point out by the way that in the file string, DO NOT put a * before the file extension
Was This Post Helpful? 0
  • +
  • -

#11 simonthes  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 08-February 12

Posted 08 February 2012 - 02:46 AM

ty
Was This Post Helpful? 0
  • +
  • -

#12 TechKid  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 3
  • View blog
  • Posts: 82
  • Joined: 04-September 10

Posted 25 November 2012 - 08:45 AM

Thanks man, this helps a lot! Is there any reason that you would prefer this method over the registry edit method?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1