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 file type in window registry for c# program ?

how to associate file type in window registry for c# program ?

Scheduled Pinned Locked Moved C#
csharpquestionwindows-admintutorial
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.
  • K Offline
    K Offline
    Kim0618
    wrote on last edited by
    #1

    Hi, I have created a program e.g. test.exe by C#.net and I want to associate file extension (eg .tst) with the test.exe in the window registry. But I found that most commercial program specifying file type in window registry by CLSID, (so the file type may be opened by the program for the dll specifid by the CLSID) which is only for dll. I have only an exe and I can specify opening the file type in the open subKey in the registry. But how can I specify the file type with a dll(CLSID) which in my case I dont have ? or how can I convert my exe into dll so I can open the file type by the dll ? Thanks

    B T P 3 Replies Last reply
    0
    • K Kim0618

      Hi, I have created a program e.g. test.exe by C#.net and I want to associate file extension (eg .tst) with the test.exe in the window registry. But I found that most commercial program specifying file type in window registry by CLSID, (so the file type may be opened by the program for the dll specifid by the CLSID) which is only for dll. I have only an exe and I can specify opening the file type in the open subKey in the registry. But how can I specify the file type with a dll(CLSID) which in my case I dont have ? or how can I convert my exe into dll so I can open the file type by the dll ? Thanks

      B Offline
      B Offline
      BobJanova
      wrote on last edited by
      #2

      This isn't really a C# question. File associations are stored in HKEY_CLASSES_ROOT/.ext. Most file types then have an almost empty key with the default value pointing to another key (typically 'extfile'). In that key, the default value is the friendly name for the type (appears in Windows Explorer and the File Types dialog). To associate the file type with a program, create a subkey Shell/open/command and for the default value in there, put the command to run (typically something like path/myapp.exe "%1").

      1 Reply Last reply
      0
      • K Kim0618

        Hi, I have created a program e.g. test.exe by C#.net and I want to associate file extension (eg .tst) with the test.exe in the window registry. But I found that most commercial program specifying file type in window registry by CLSID, (so the file type may be opened by the program for the dll specifid by the CLSID) which is only for dll. I have only an exe and I can specify opening the file type in the open subKey in the registry. But how can I specify the file type with a dll(CLSID) which in my case I dont have ? or how can I convert my exe into dll so I can open the file type by the dll ? Thanks

        T Offline
        T Offline
        Tony Pazzard
        wrote on last edited by
        #3

        Have done somethingg similiar. In the code below the file extension to be opened by the app is .stockcheckdata . This extension then needs to be associated with app, in my example the one being opened.

        Registry.ClassesRoot.CreateSubKey(".stockcheckdata").SetValue("", "stockcheckdata", RegistryValueKind.String);

        Registry.ClassesRoot.CreateSubKey(@"stockcheckdata\shell\open\command").SetValue("", Application.ExecutablePath + " \" %1 \"", RegistryValueKind.String);

        Hope it helps?!

        1 Reply Last reply
        0
        • K Kim0618

          Hi, I have created a program e.g. test.exe by C#.net and I want to associate file extension (eg .tst) with the test.exe in the window registry. But I found that most commercial program specifying file type in window registry by CLSID, (so the file type may be opened by the program for the dll specifid by the CLSID) which is only for dll. I have only an exe and I can specify opening the file type in the open subKey in the registry. But how can I specify the file type with a dll(CLSID) which in my case I dont have ? or how can I convert my exe into dll so I can open the file type by the dll ? Thanks

          P Offline
          P Offline
          PIEBALDconsult
          wrote on last edited by
          #4

          Try double-clicking the file and then tell Windows which app to use to open it.

          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