PDA

View Full Version : Where to read an ini file



NewsArchive
03-12-2008, 02:49 AM
Hi all,
during the first installation of a program I ask for a certain
folder and then I create an ini file there with some information.
I want that, if I reinstall the program, after choose the same
folder, search for the ini file and retrieve the information that I
saved before.
Question is: how and where should I do it?
Thanks in advance.

--
Mauricio
Copenhague, Dinamarca

NewsArchive
03-12-2008, 02:49 AM
Hi Mauricio,

> during the first installation of a program I ask for a certain
>folder and then I create an ini file there with some information.
> I want that, if I reinstall the program, after choose the same
>folder, search for the ini file and retrieve the information that I
>saved before.
> Question is: how and where should I do it?

I use the registry for this sort of thing. It's simpler because it's
all in one place and it's easy to work with both in your application
and in SB:)

Best regards,

Arnór Baldvinsson
Icetips Creative, Inc.
San Antonio, Texas, USA
www.icetips.com


Subscribe to information from Icetips.com:
http://www.icetips.com/subscribe.php

NewsArchive
03-12-2008, 02:50 AM
Thanks Arnor. The problem in this case is that we've decided not to use
the registry. :-(
I need to look for the ini after choose the folder and show the values
in the next dialog.
Any idea?
Thanks again.




--
Mauricio
Copenhague, Dinamarca

NewsArchive
03-12-2008, 02:50 AM
Hi Mauricio,

>Thanks Arnor. The problem in this case is that we've decided not to use
>the registry. :-(
>I need to look for the ini after choose the folder and show the values
>in the next dialog.
>Any idea?

You can use the "Select File Dialog" and let the user select the file.


Or once they select the install folder, you can simply try to read the
values from the ini file using the "Get INI Value..." statement. I
don't think there are any file searching functions in SB, but you
might be able to write your own dll to do it with.

It sounds to me that the decision to not use registry may not be the
best design in this case. It is very good for storing information
like this as then there is only one place to look for it:)

Best regards,

Arnór Baldvinsson
Icetips Creative, Inc.
San Antonio, Texas, USA
www.icetips.com


Subscribe to information from Icetips.com:
http://www.icetips.com/subscribe.php

NewsArchive
03-12-2008, 02:51 AM
Hi again, Arnór
I saw the Get Ini Value... my question is where exactly to put this
statement? In my case it's like I have to call it after Next button in
the Choose Folder Window is pressed, but I couldn't find any embed
point for that button :)
Thanks again.

--
Mauricio
Copenhague, Dinamarca

NewsArchive
03-12-2008, 02:52 AM
Hi Mauricio,

> I saw the Get Ini Value... my question is where exactly to put this
>statement? In my case it's like I have to call it after Next button in
>the Choose Folder Window is pressed, but I couldn't find any embed
>point for that button :)

You call it inside the Loop Wizard, like this:

Loop Wizard (Abort Dialog Inactive)
! *** ICETIPS: These checks must be in place to check for username and update clarion path
If %_SB_DIALOGID% Equals "5" Then
If %IT_USERNAME% Equals "" Then
Cycle Loop
/* Send OutputDebugString "Username Empty" */
Else
/* Send OutputDebugString "Username entered" */
End
End
If %_SB_DIALOGID% Equals "6" Then
Set Variable %_SB_INSTALLDIR% to "%IT_CLARIONDIR%"
Set Variable %IT_CLARIONVERSION% to "%_SB_RETURN%"
Refresh Next Dialog
End
End

HTH:)

Best regards,

Arnór Baldvinsson
Icetips Creative, Inc.
San Antonio, Texas, USA
www.icetips.com


Subscribe to information from Icetips.com:
http://www.icetips.com/subscribe.php

NewsArchive
03-12-2008, 02:53 AM
THANKS!!!!!

--
Mauricio
Copenhague, Dinamarca

NewsArchive
03-12-2008, 02:54 AM
Mauricio,

> I saw the Get Ini Value... my question is where exactly to put this
> statement? In my case it's like I have to call it after Next button in
> the Choose Folder Window is pressed, but I couldn't find any embed
> point for that button :)
> Thanks again.

See attached "quick and dirty" DataFolder.sb6 demo project and source code
snippet.

The Select Destination Folder is displayed. After that the installer tries
to read the data folder path from a config.ini located in the installation
folder. If it is not found, the default is set to c:\test. The path is
written to an INI.

Does this help?

Friedrich

--
Friedrich Linder
Lindersoft
www.lindersoft.com
+1.954.252.3910

"point. click. ship" - that's SetupBuilder 6.7
Create Windows Vista ready installations in minutes

-- Official Comodo Code Signing and SSL Certificate Partner

NewsArchive
03-12-2008, 02:55 AM
First question might be WHY you're doing it that way rather than saving your
information in the Registry.

Do you only want to read that file if the user reinstalls into the same
folder?

Jane

NewsArchive
03-12-2008, 02:56 AM
Hi Jane,
as I told Arnor, we have decided not to use the registry, that's the
problem.
There are 2 windows in the setup (among others). The first one asks
for the folder where the program will be installed. After this, there
is a new windows to fill up with data for connecting to a MS SQL
database (server, database, user and password). I need to show this
variables if the ini file already exists.
Thanks for your answer.

--
Mauricio
Copenhague, Dinamarca

NewsArchive
03-12-2008, 02:56 AM
Well, then... you'll want to look for the INI file at the beginning of the
setup script and update/create it at the end.

I'd probably do something like
1. Check the default installation folder location for the INI file.
2. If not there, enumerate a list of drives on the computer (Get System
Information script item, choose Enumerate Disk Drives), then use the Search
For File script item to hunt through each drive on the user's computer to
find your main .exe file, which is presumably in the folder he's already
installed in.

HTH

Jane

NewsArchive
03-12-2008, 04:50 AM
Friedrich,
is DataFolder.sb6 an example project? Because I couldn't find it in
my computer.
I have also downloaded the examples from your page.
Thanks.

--
Mauricio
Copenhague, Dinamarca

NewsArchive
03-12-2008, 04:58 AM
Hi Mauricio,

> is DataFolder.sb6 an example project? Because I couldn't find it in my
> computer.
> I have also downloaded the examples from your page.

I have created the DataFolder.sb6 project for you (see previous message,
attached DataFilder.zip).

Friedrich

NewsArchive
03-13-2008, 02:13 AM
Thanks Friedrich, I didn't see the file. I think it's time to change my
glasses. :D

--
Mauricio
Copenhague, Dinamarca