- NSIS Discussion
- INI file
Archive: INI file
xma
8th July 2009 08:44 UTC
INI file
Hi evryone,
I am trying to add components to the page directory of the installer.
I use ressource hacker to add groupbox, bouton, etc..
Now those components are visible when i launch this installer but i can t use them in my code to specify their use.
For exemple, I would like my button to be a dirRequest.
I think I have to declare them in a file .ini but I don't know where I can get the ini file for the default installation pages in order to add field for the components
If someone can help me it will be greatfull
Thank you
jpderuiter
8th July 2009 14:12 UTC
You have to use the ButtonEvent Plugin: http://nsis.sourceforge.net/ButtonEvent_plug-in
Read the readme in the zip for more info.
xma
8th July 2009 17:57 UTC
Thanks for your reply :)
I was reading doc of ButtonEvent. I don't think i can't make this button become a DirRerquest like the one which is already exist in the directory page.
I am newbie and maybe I am not doing the right thing to obtain what i want.
I just need to add another directory request in the default MUI_PAGE_DIRECTORY.
Do you have any ideas to do that because i am looking evrywhere and i can't get a solution to my problem ?
Thank you
Afrow UK
8th July 2009 22:14 UTC
Easier just to add another MUI_PAGE_DIRECTORY.
Stu
jpderuiter
8th July 2009 22:24 UTC
OK, if you just need a second directory page, you can do three things:
- Use two Directory pages: (http://nsis.sourceforge.net/Two_inst..._one_installer)
- Add a textbox and a browse button with resource hacker, add a callbackfunction for the browse button, and call the DialogsEx plug-in (http://nsis.sourceforge.net/Dialog****plug-in) in this callback to show a folder browse dialog box.
- Don't use the standard Directory page, and create your own custom page with two nsDialogs DirRequest controls.
JP
Afrow UK
8th July 2009 22:40 UTC
That example with two directory pages is probably more than you need as it also has two components and instfiles pages. To have two directory pages you just need to specify a different variable to use for the second using !define MUI_DIRECTORYPAGE_VARIABLE INSTDIR2 (say).
Stu
xma
9th July 2009 09:55 UTC
Thanks for your reply i really appreciate :)
I know that we can add another MUI_PAGE_DIRECTORY but really want to put the two DirRequest in the same page.
So i might use the second solution of JP but I am not familiar to callback function and plugin.
If i use this plugin does the path of the folder will appear in the textbox? will INSTDIR2 be automatically the variable for the second DirRequest ?
I'm going to have a look of the plugin and try to use it.
jpderuiter
9th July 2009 11:59 UTC
With the callback function I meant using the ButtonEvent Plugin I mentioned before.
xma
9th July 2009 12:42 UTC
Ok, as I'm not very familiar with plugin i decide to create my own custom directory page to replace the default MUI_DIRECTORY_PAGE.
Now I would like to know how can I insert a default path to each DirRequest (Like $InstDIR before)
I tried with MUI_INSTALLATIONS_WRITE but it doesn't seem to work.
Do you have any idea ?
Thank you
MSG
9th July 2009 12:55 UTC
Assuming you're using nsDialogs to create your custom page: You can set the default path in the dir request creation macro, like this:
${NSD_CreateDirRequest} 10u 85u 210u 12u "YOUR DEFAULT GOES HERE"
jpderuiter
9th July 2009 12:56 UTC
You can set the root of a DirRequest in an InstallOptions ini file with
!insertmacro MUI_INSTALLOPTIONS_WRITE "CustomDialog.ini" "Field 1" "Root" "c:\Program Files\xyz"
(Note the MUI_INSTALLOPTIONS_WRITE instead of MUI_INSTALLATIONS_WRITE).
However, I recommend using nsDialogs instead of InstallOptions .
xma
9th July 2009 13:51 UTC
I am using IstallOptions... Sorry
I have tried to put a Root parameter but i still can't see the path in the TextBox !
However I would like to put a variable instad of "C:\...\" like INSTDIR for exemple. I need to switch the both default path if the user is admin or not.
Thanks again for your help :)
xma
9th July 2009 15:28 UTC
If I have understand,
MUI_INSTALLOPTIONS_WRITE allow to write dynamicly in the ini file :
!insertmacro MUI_INSTALLOPTIONS_WRITE "NewDirectoryPage.ini" "Field 2" "Text" "$INSTDIR"
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "NewDirectoryPage"
So after this instruction the textbox of the DirRequest should show my INSTDIR value... but it doesn't happen.
Do you have any explaination ?
I extract the ini file in my function .oninit
Afrow UK
9th July 2009 16:49 UTC
You have some inconsistencies here. Are you extracting as NewDirectoryPage.ini or NewDirectoryPage? You are writing to NewDirectoryPage.ini but showing NewDirectoryPage.
Stu
xma
9th July 2009 17:30 UTC
Exactly I was writing the wrong file... Hard day...
Thank you
jpderuiter
9th July 2009 17:54 UTC
And you should set the "State" field to $INSTDIR instead of the "Text" field.
xma
10th July 2009 09:50 UTC
Thanks JP i changed that.
So now in my DirRequest textbox i have $PROGRAMFILES or $APPDATA depending on the user status. But the user can still change the directory and i can't get dynamicly the path he entered. I would like his choice become the $INSTDIR variable. I tried with this :
!insertmacro MUI_INSTALLOPTIONS_READ $INSTDIR "NewDirectoryPage" "Field 2" "State"
but that doesn't change anything.
Is there a way to do this ?
Afrow UK
10th July 2009 10:25 UTC
That will work if done from the leave function. If that is what you are doing then post some code. You can also put in some message boxes to pause the installer then you can look in %TEMP%\ns???.tmp\* to find your INI file.
Stu
xma
10th July 2009 10:37 UTC
Thanks
Exactly what i tried and it works now !!
xma
13th July 2009 10:42 UTC
I really want to thank you for your help :)!
I put this discussion to resolve
xma
13th July 2009 10:44 UTC
[RESOLVE]Originally posted by xma
I really want to thank you for your help :)!
I put this discussion to resolve [/QUOTE]