Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

File Extensions

  1. May 4, 2003 #1
    Hi guys. I have a question about file extensions.

    For example, if you create a .txt file, windows seems to know automatically that it is a file that can be opened by notepad or wordpad. It gives it a specific icon, and opens it inside notepad or wordpad.

    If I wanted to create a program that saved data in a file extension like .psh (my initials) I know I can do it. But exactly what do I need to code to make windows regonise the extension and give the file a particlular icon, and open up it up in my program etc?

    I guess one obvious thing is that my program must be able to recognise the file type and "decode" it.
  2. jcsd
  3. May 4, 2003 #2
    You need to add the filetype into the registry, which keeps track of that stuff. If you go into Tools->Folder Options->File Types you can browse the associations and enter it manually. If you want your program to do it, use the Registry API functions and put the info in HKEY_CLASSES_ROOT -- you can browse with regedit to see how it's structured, or there are plenty of online tutorials and code snippets.
  4. May 5, 2003 #3
    Thanx for the info Damgo.

    Once this session is over at uni I'll have to take a look around the net for some tutorials on the subject.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook