Jump to content

How to create a new file format


Recommended Posts

name it what ever you want like: myrandomfileTxTediTor.TxTediTorfile and then if i remember right you should create some regedit keys so it can be open from your context menu ( cant remember what keys)

My Scripts:Radioblog Club Music DownloaderOther stuff:Fun movieIm serious read the help file it helps :PFight 'Till you drop. Never stop, You Cant give up. Til you reach the top Fight! you’re the best in town Fight!
Link to comment
Share on other sites

name it what ever you want like: myrandomfileTxTediTor.TxTediTorfile and then if i remember right you should create some regedit keys so it can be open from your context menu ( cant remember what keys)

If i remember correctly I think its just in

HKEY_CLASSES_ROOT

but i could be delusional..

Link to comment
Share on other sites

I would not recommend you do it by Registry keys. I recommend you use FTYPE and ASSOC to create file extensions and associations:

Run(@ComSpec & " /c " & 'FTYPE STxtDoc="' & @ProgramFilesDir & '\My Program\MyProgram.exe" "%1"', "", @SW_HIDE)
Run(@ComSpec & " /c " & 'ASSOC .ShideTxt=STxtDoc', "", @SW_HIDE)

You can of course change the document type name "STxtDoc" to whatever you want. You can also change the .ShideTxt extension to anything you like as well. You will also have to change the full path location of the program that opens it.

Keep in mind, when your program is executed, the first command line will be the location of the text file that it has to open. As a result, you will need to use $cmdline to determine if a command line has been given to your main program. If a command line is given and the first parameter is a full path to the document that it must open, the main program should then immediately open that document upon loading.

-The Kandie Man

Edited by The Kandie Man

"So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire

Link to comment
Share on other sites

hmm, I've always done it by reg keys, if you don't mess with anything you don't know about, you're probably not going to break anything. Actually, don't mess with anything at all, just add stuff.

Of course, if you aren't farmiliar with regedit, you should get familiar with it before following these steps, otherwise you COULD mess something up.

----------------------

THE FOLLOWING WILL CHANGE YOUR REGISTRY. I AM NOT RESPONSIBLE IF YOU BREAK OR DAMAGE YOUR COMPUTER BY DOING THIS WRONG.

Add a new reg key in HKEY_CLASSES_ROOT called ".yourext" (obviously name it what you want, but keep the . in front)

In that new key, set the default value to a UNIQUE one-word description of your file type. alphanumeric values ONLY. for example, "ShidesTxTediTor" (without the quotes)

create another new key in HKEY_CLASSES_ROOT with its name as the description you put in the step above. It must be exactly the same, and case does count.

In that new key, set the default value as another description. this one can have spaces, and it's the one that will show up on the user's computer. For example, "Shides TxTEdiTor File" (no quotes)

Create another new key, but this time inside the second key you created. call it "shell". no caps or anything. just shell. in there, set the default value as "open".

Then create ANOTHER key under shell. call it "open". It has no default value, just leave it alone.

Create another key under open called "command". There, set the default value as this:

"PATH TO YOUR EDITOR" "%1"

including the quotes. Don't change anything other than the path to your editor. Leave the percent sign and everything.

----------------------

That's it! you now have your own new nifty extension. Just set your program to accept command line files, and that's it. Have it automatically open the file in the command line. That will be automatically set to $CmdLine[1]

edit: but of course, Kandie Man's solution works too, however, it doesn't offer as much control as you can get with direct registry modification. If you are not comfortable with the registry, I suggest using his solution.

Edited by theguy0000

The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Link to comment
Share on other sites

  • 3 weeks later...

Add a new reg key in HKEY_CLASSES_ROOT called ".yourext" (obviously name it what you want, but keep the . in front)

In that new key, set the default value to a UNIQUE one-word description of your file type. alphanumeric values ONLY. for example, "ShidesTxTediTor" (without the quotes)

create another new key in HKEY_CLASSES_ROOT with its name as the description you put in the step above. It must be exactly the same, and case does count.

In that new key, set the default value as another description. this one can have spaces, and it's the one that will show up on the user's computer. For example, "Shides TxTEdiTor File" (no quotes)

Create another new key, but this time inside the second key you created. call it "shell". no caps or anything. just shell. in there, set the default value as "open".

Then create ANOTHER key under shell. call it "open". It has no default value, just leave it alone.

Create another key under open called "command". There, set the default value as this:

"PATH TO YOUR EDITOR" "%1"

hi there !

maybe there is anyone who can post the few lines that are needed to execute the file registration from within a script in the way theguy0000 described it ?

(and maybe an example for the $cmdline detection, too)

thanx

j.

Edited by jennico
Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...