Understanding File Extensions & How To Create Your Own

  • Thread starter Pauly Man
  • Start date
  • Tags
    File
In summary, the conversation discusses how to create a program that can save data in a custom file extension. It mentions that in order for Windows to recognize the extension and give it a specific icon, the file type needs to be added into the registry. This can be done manually or using the Registry API functions. The conversation also mentions the availability of online tutorials and resources for coding this functionality.
  • #1
Pauly Man
129
0
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.
 
Computer science news on Phys.org
  • #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.
 
  • #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.
 

FAQ: Understanding File Extensions & How To Create Your Own

What is a file extension?

A file extension is a set of characters that come after the last period in a file's name, indicating the type of file and the program used to open it.

Why do we need file extensions?

File extensions help us identify the type of file and determine which program to use to open it. They also help computers recognize and organize files.

How do I create my own file extension?

To create your own file extension, you need to first decide on a unique name for your extension. Then, you can use a text editor or a programming language to create a new file and save it with your chosen name and a period before it. For example, "mydocument.mde".

Can I change a file's extension?

Yes, you can change a file's extension by renaming the file and replacing the current extension with the one you want. However, changing a file's extension may make it unreadable or cause it to open with the wrong program.

Are file extensions case sensitive?

Yes, file extensions are case sensitive, meaning that "mydocument.txt" and "MyDocument.TXT" are considered two different file types.

Similar threads

Replies
4
Views
2K
Replies
17
Views
7K
Replies
20
Views
2K
Replies
22
Views
2K
Replies
33
Views
2K
Back
Top