Archive: file association


file association
hi!

actualy i have 4 questions:

1. i need to make multiple file associations. does anyone know how? and how do i UNassociate at uninstall?

2. how to make if win9x is installed o install file1 and if win2000, winxp is installed, to install file2?

3. can i make (i did not tried yet this one !) a custom page to display something like this with a chekbox : "associate .123 files with file1.exe"?

4. i am a bit confused. i have 6 sections at install. but at uninstall there is only one section. right?
if the user selects only 2 sections at install, NSIS knows that were selected only 2 sections? because if not, that means it deletes a lot of files that are not mine. (sorry for bad english). or if i am wrong, please tell me how to correct this.

thanks.


1. Examples\makensis.nsi associates file extensions, you can use it as an example.

2. Use GetWindowsVersion.

3. Use InstallOptions to display custom made pages. See Examples\Modern UI\InstallOptions.nsi if using the MUI or Contrib\InstallOptions\test.nsi if not.

4. The uninstaller doesn't remember the sections choosen in the installer. If you need to know exactly which sections where choosen you can write the selection (using GetSectionFlags to find out if they were selected) to an INI file or the registry and then read those values at uninstall time.


question 1 is ok. i associated the extensions.
question 2 - working now.
question 3 is ok. i creted my custom page. the user can associate file extensions with a program.
question 4 - not yet.

but i have to combine q1 with q3. how can i do this: the custom page to be displayed only if a section from the installer has been selected ? and how to associate the file extensions only if the checkbox from the custom page has been selected ?



another question. can anyone tell me was this lines mean (from the .ini file required for the custom page):
Left=0 - space from the left side. right ?
Right=-1 - ???
Top=0 - ???
Bottom=10 - ???

thanks.


To skip a page according to section selection see:
http://forums.winamp.com/showthread....m+page+section

To read the values entered by the user in the custom page see one of the InstallOptions examples.

Left, Right, Top and Bottom define a rectangle in which the control will be created. Left and Right values are distances from the left side of the page, Top and Bottom are the distances from the top side of the page. If the value is negative it's the distance from the oppsite side. For example, Right is -1 in your example so it's distance from the left side of the page will be PageWidth - 1.


hello again!

i changed my code as is "Contrib\InstallOptions\test.nsi" and the file extension association does not work. i can't see what is wrong, so i attach the function. help! please !

PS: 1. i opened regedit.exe and look for ".xvid" extension. it does not exist in registry
2. the state of the checkbox is "1" (default in .ini file)


I can tell much without the whole code but I bet it just doesn't find Tasks.ini. Specify a full path as in the example - $PLUGINSDIR\test.ini (assuming you've extracted it to the $PLUGINSDIR). I also think it'll be a better idea to put this code in a section so it will only register the file type if the user actually got to installation step.


thanks very much for super fast response, kichik !

i changed the code as you said and it works. but what does $PLUGINSDIR mean ?
let me rephrase : where would be my file extracted ? in a temp directory ?

about the question with the uninstall section, can you point me to an example ?

thanks again.!


$PLUGINSDIR is a special directory for plug-in used by NSIS and other temporary files used by the installer. It's directory name is random but it's always in the temporary directory.

Hmm... Example of what? Of writing the section selection into an INI file? If that's the case all you need is:

SectionGetFlags ${sectionDefinedName} $0
IntOp $0 $0 & ${SF_SELECTED}
WriteIniStr myFile.ini uninstallSection section1 $0

for every section you have. It will write 1 if the section is selected and 0 if it's not.


You can also write a value to the ini file in the end of each section. It will only be written if that section executed which means it was selected.


hello again, is tried with this example

Originally posted by kichik
SectionGetFlags ${sectionDefinedName} $0
IntOp $0 $0 & ${SF_SELECTED}
WriteIniStr myFile.ini uninstallSection section1 $0

for every section you have. It will write 1 if the section is selected and 0 if it's not.
i have no errors and no warnings, but "1" is not written to file. the path is correct. i put the code in "Section -post" of the installer.
how do the ini file should look like ?
mine is like this:

[uninstallSection]

section1=0
section2=0
section3=0
section4=0
section5=0
section6=0

sorry for all the (probably) stupid questions.

thanks.

Do all of the defines (${sectionDefinedName}) have the right value or are they all zero?

Don't worry about asking, ask until you understand.


the script is already attached in

http://forums.winamp.com/showthread....hreadid=136925

i attach the ini file to.

nothing changes in it. everything remains with "=0".

thanks for helping.


You should not extract a default INI file but let the code create it for you. You must inlcude the code above for every section in the script, not just the first section. If it still doesn't work try giving a full path to WriteIniStr ($INSTDIR\install.ini).


ok. it works. the uninstall part too. it's ok. thanks very much.