Skip to content
⌘ NSIS Forum Archive

How to Register File Types?

11 posts

mcrbids#

How to Register File Types?

I'm attempting to write an installer for a php-gtk program. I've figured out most of it, except that I need to register the ".php" filetype with the correct executable so that the application will actually run.

I can't find this anywhere in the documentation... how do I do this?

I want to register the ".php" filetype with application

c:\Program Files\php4\php_gtk.exe

Thanks!
Vytautas#
What you need is to create some registry keys/enties in
HKEY_LOCAL_MACHINE\Software\Classes
first you need to create a ".php" key with the description of the file type. Then create a key with the description as the name.

Check the registy for some examples of the keys/entries.

Vytautas
kichik#
The NSIS installer registers .nsi and .nsh. Its source code can be found in Examples\makensis.nsi. Is someone up to creating an Archive page for this?
kichik#
Thanks.

The code you've copied also backups the old value so it would be nice if you include the uninstall part too that shows the reinsertion of the backuped value.
Vytautas#
Updated archive page to include restoration script for uninstaller. Thanks kichik for pointing this out.

Vytautas
Guest#
Note

Jsut wanted to add, that according to the MSDN, it's important to notify the system that you have made a change. You do this with the function SHChangeNotify. To notify Windows of a file association change, call the function like this:

SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_DWORD, NULL, NULL);

If you do not call this function, Windows might not recognize your new filetype, or the change you made, before the system has been restarted.

Best regards
René Gundersen (rene@alquesm.dk)
dandaman32#
Use the System plugin.
System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) v (0x08000000, 0, 0, 0)'
-dandaman32
IGC#edited
I have a question regarding this...

I was able to register the .igc extensions with my program.
Everytime I click on one of the .igc files the program executes correctly BUT..

The parameter passed to the program (the .igc file clicked) has a limited length. When that limit is passed the parameter contains tildes (~) on the path and in the filename.

For example: I click on "D:/Documents/My_files/igc_files/file to open.igc", my program executes, but the paramter passed to the program is something like: "D:/DOCU~/MY~/IGC~/FILET~1.igc"

When this happens my program can't find the passed file and it is not opened.

How do I solve this problem?

It does not affect the execution of the program, and if I use the Open button on my program the files open correctly, but it is an extrange behaviour that can be viewed as a bug on the code...

EDIT:
I found the source of the problem...
after shell\open\command I forgot to put quotes between the path to my executable. I do not know how that affects the arguments passed to the program, but it does.
Everything works perfect now.