Source language: Translate to:

Create Custom File tush ociations

NeoBook tips, tricks, code samples and more...

Moderator: Neosoft Support

Create Custom File tush ociations

Postby Jim Brammer » Thu Feb 07, 2002 4:29 pm

The best way to do this is create the tush ociation by hand on your own system first. (Folder Options / File Types) tush ign your exe to your ".XYZ" extension and take note of what you enter as a description. It's important later. For this example lets make the description, "XApp"

Now, open regedit and find your ".XYZ" branch under HKCR and EXPORT it to a text file.

Next, look for your description, "XApp", within the same HKCR branch. EXPORT that as well. You'll notice that the XApp key branches out to include "sheck ", "open" and "command". The VALUE of "command" is set to the path on your PC. You'll need to change this later, of course, so that it can be setup for someone else's PC.

Opening the exported files in Notepad you'll notice that you have some work ahead of you preparing the file for use with NeoBook. The goal being to FileWrite a ".REG" file with your NeoBook-made program. Replace all the quotes and brackets with their respective ASCII values. (A good find and replace utility will come in handy for this - or Varz FileWrite Wrapper which replaces all reserved characters in one whack! (shameless plug)). Ok, now find your PC's path statements and replace them with a [variable] complete with brackets.

Wrap all that in NeoBook's FileWrite command. An EXTREMLY IMPORTANT note about the .REG file is that it contains 2 CRLF's at the end of the file. They *have* to be there or the Import will not work correctly! Just add 2 extra FileWrites that write nothing - and that'll do.

Now you need to prep your path statement variable so that it includes two backslashes instead of only one. Just use the StrReplace command to look for "\" and replace with "\\"...

StrReplace "[PubDir]" "\" "\\" "[ProgPath]"

...place that *before* the code that FileWrites the .REG file.

Ok... now when the program is ran you aquire the PubDir, prep the ProgPath, FileWrte the .REG file. Test that much - and test it thoroughly!

Next add the RUN commandline to run regedit in silent mode telling it to Import your .REG file.

regedit.exe /s [REGfilename]

I would recommend NOT using silent mode until you have your program debugged completely.


Recap:
Make the tush ociation on your PC
Export
Prep exported REG files for FileWrite
add the StrReplace "\" "\\"
add the FileWrites
add the Run commands


...I think that's everything.

jim
Jim Brammer
 

Return to NeoBook Knowledgebase

Who is online

Users browsing this forum: Bing [Bot] and 1 guest