Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How to associate files with programs?

How to associate files with programs?

Scheduled Pinned Locked Moved C#
tutorialquestion
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nogola
    wrote on last edited by
    #1

    How to make Windows open specific files with a specific program??? Lets say i make a program which saves something to .fil -files, how to associate .fil files to my program ???

    E K I 3 Replies Last reply
    0
    • N nogola

      How to make Windows open specific files with a specific program??? Lets say i make a program which saves something to .fil -files, how to associate .fil files to my program ???

      E Offline
      E Offline
      Ed Poore
      wrote on last edited by
      #2

      Look at the registry keys in HKEY_CLASSES_ROOT, sorry I don't have time at the moment to explain further, if I get the time tomorrow and you haven't sorted it I'll explain it more thoroughly. Ed

      1 Reply Last reply
      0
      • N nogola

        How to make Windows open specific files with a specific program??? Lets say i make a program which saves something to .fil -files, how to associate .fil files to my program ???

        K Offline
        K Offline
        kasik
        wrote on last edited by
        #3

        If you open your registry using regedit, and select HKEY_CLASSES_ROOT, you will see an enormous list of, amongst others, file extensions. Like...

        *
        ._sln
        .txt
        .rar

        and so on. Each of these registry keys has their default string value set to the name of another key in HKEY_CLASSES_ROOT, like .rar has its default value set to WinRAR. If you go to the WinRAR key in HKEY_CLASSES_ROOT, it will have various properties to it. Its default value is set to the what the file is for - "WinRAR Archive" in this case. A sub key of the WinRAR key is shell which in turn has a sub key open. The default value of the open key is what you want to appear as the default menu item in the context menu that is shown when a user right-clicks on a file of this type in Windows Explorer. Inside this key is another sub key called command. The default value of this is where you can set the program you want to launch when someone opens the file. You can use "%1" to represent the file path - so if you wanted to load the file in notepad, you could set the default to

        "notepad.exe" "%1"

        So an example hierarchy for a new file type of extension .fil, if you wanted to launch it with say "MyApp" could be...

        HKEY_CLASSES_ROOT
        -> .fil
        * (Default) = filfile
        -> filfile
        * (Default) = fil File
        -> shell
        -> open
        * (Default) = Open this fil file with MyApp
        -> command
        * (Default) = "C:\Path To MyApp\MyApp.exe" "%1"

        (where '->' represents a key, and '*' represents a value) Hope that helps (and makes sense) :) Cheers, Will H

        1 Reply Last reply
        0
        • N nogola

          How to make Windows open specific files with a specific program??? Lets say i make a program which saves something to .fil -files, how to associate .fil files to my program ???

          I Offline
          I Offline
          IceWater42
          wrote on last edited by
          #4

          I am not a big fan of messin around with the registry. I'm running XP so this is what i would try: open any folder. Under the Tools menu ... select Folder Options Under Folder Options ... select File Types I've never done it, but it looks like you can make a file association right there. Just press the NEW button, enter the file extension and press okay. This will cause the new file extension to be displayed (and selected) along with all the others. Next, press the CHANGE button next to the "Opens with" thingie, locate the program you wish to associate with that extension, and you are in business ... maybe, hopefully, possibly ... lol. Good luck :)

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups