I'm writing a java program and I need to create a save file with an extension invented by me and the file should also have an image chosen by me. Can anyone tell me how to do it?
Asked
Active
Viewed 32 times
0
-
1when you say "image" what do you mean? – Jose Martinez Mar 24 '19 at 19:25
-
for example, when in Photoshop (or others) except a project, the save file has the symbol of Photoshop as an icon: I mean that. – Javissimo Mar 24 '19 at 19:27
-
1You need to configure your OS to associate an icon to a file extension. Java can't do that by itself. – JB Nizet Mar 24 '19 at 19:28
-
Ok so it must store binary data. Have you tried using Java serialization? – Jose Martinez Mar 24 '19 at 19:28
-
would you please direct me to a link explaining how to do this? – Javissimo Mar 24 '19 at 19:29
-
initially I wanted to use it but serialization in my opinion is too dangerous, as you just need to change a line of code in the class and you can't read the contents of the serialized file before – Javissimo Mar 24 '19 at 19:31
-
Do you want to create the file with own icon image? – Valentyn Hruzytskyi Mar 24 '19 at 19:31
-
yes I wont create a file with own icon image – Javissimo Mar 24 '19 at 19:32
1 Answers
0
How can i assign icon for my custom file extension?
It's a system behaviour you can't alter this unless you change the registery in your machine.
to achive this you need to modify the registery in the deployed system (google for this you'll find links)
you need use RegOpenKeyEx(), RegGetValue(), RegSetKeyValue(), and don't forget to RegCloseKey()
Here's a link to the reference: http://msdn.microsoft.com/en-us/library/ms724875(VS.85).aspx
HKEY_CLASSES_ROOT/
this call to SHChangeNotify
this tell explorer to refresh the icon whenever it changes.

Jayanth
- 5,954
- 3
- 21
- 38