Archive: INI file


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


You have to use the ButtonEvent Plugin: http://nsis.sourceforge.net/ButtonEvent_plug-in

Read the readme in the zip for more info.


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


Easier just to add another MUI_PAGE_DIRECTORY.

Stu


OK, if you just need a second directory page, you can do three things:

  1. Use two Directory pages: (http://nsis.sourceforge.net/Two_inst..._one_installer)
  2. 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.
  3. Don't use the standard Directory page, and create your own custom page with two nsDialogs DirRequest controls.
JP

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


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.


With the callback function I meant using the ButtonEvent Plugin I mentioned before.


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


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"


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 .

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 :)


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


You have some inconsistencies here. Are you extracting as NewDirectoryPage.ini or NewDirectoryPage? You are writing to NewDirectoryPage.ini but showing NewDirectoryPage.

Stu


Exactly I was writing the wrong file... Hard day...
Thank you


And you should set the "State" field to $INSTDIR instead of the "Text" field.


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 ?


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


Thanks
Exactly what i tried and it works now !!


I really want to thank you for your help :)!
I put this discussion to resolve


[RESOLVE]Originally posted by xma
I really want to thank you for your help :)!
I put this discussion to resolve
[/QUOTE]