View Full Version : How to update ini-files
NewsArchive
12-05-2009, 08:17 AM
Hi Friedrich,
we have an ini-file with two sections
[custom]
and
[standard]
What we ship is an ini-file with entries in the [standard]-section and
an empty [custom]-section.
The customer can add entries in the [customer]-section but he is not
allowed to change the [standard]-section.
During an update, setup should update the [standard]-section with the
entries from the ini-file shipped with the update (this means: update
existing entries, remove no longer existing entries, add new entries)
but it should leave the [custom]-section untouched.
How can I do this with SB in a smart way?
Thanks in advance.
Markus
NewsArchive
12-05-2009, 08:17 AM
You've looked at the "Get INI value" and "Edit INI file" script items?
If you don't need to read items but just to remove/replace as you indicate,
the Edit Ini file should do what you want (check the help file for details).
Jane
NewsArchive
12-07-2009, 04:16 AM
Hi Jane,
Thanks for you reply. I know the "Edit INI file" script item. But it
seems not to do what I want for three reasons:
First: It requires to change the setup my default-INI-File change, but
the ini-file is created by another developer. For that, I would need a
preprocessor command to import the contents from a given ini file during
the setup build process.
Second: It seems not to be possible to create an empty section.
Third: It seems not to be possible to remove all unkown entries in a
given section.
I'm sure, you or FRiedrich has further suggestions. Thanks.
Markus
NewsArchive
12-07-2009, 04:17 AM
Markus,
> Second: It seems not to be possible to create an empty section.
>
> Third: It seems not to be possible to remove all unkown entries in a given
> section.
If you have the following "Contents", it should delete the [custom] section:
[custom]
=
It's not possible to create an "empty" section.
BTW, "Edit INI File" wraps around WritePrivateProfileString:
http://msdn.microsoft.com/en-us/library/ms725501(VS.85).aspx
It should be possible to use "Call DLL" to directly use this API.
Friedrich
NewsArchive
12-08-2009, 09:39 AM
Thanks, Friedrich.
You have not reply to "First". I guess, you a working on somthing for
that... Right?
Markus
NewsArchive
12-08-2009, 09:39 AM
Hi Markus,
> You have not reply to "First". I guess, you a working on somthing for
> that... Right?
#get ini... can read values from an INI.
Friedrich
NewsArchive
12-08-2009, 09:40 AM
Hi Friedrich,
that's complicated. As far, as I can see, if I want to use "#get ini..."
setup has to know, which entries exists in the ini file, but thats not
possible. And I can't use this unknown entries in the "edit ini file
script".
What I wish is a functionality similar to the macros "file://" and
"local://" (from License Agreement Dialog) for the "edit INI file"
script Item. Is this possible?
Markus
NewsArchive
12-08-2009, 09:40 AM
Hi Markus,
> that's complicated. As far, as I can see, if I want to use "#get ini..."
> setup has to know, which entries exists in the ini file, but thats not
> possible. And I can't use this unknown entries in the "edit ini file
> script".
Yes, that's correct. You have to know the name of the specific setting for
which to return the value. It's not possible to retrieve all the "INI
Items" in the section specified by the "INI Section" parameter.
> What I wish is a functionality similar to the macros "file://" and
> "local://" (from License Agreement Dialog) for the "edit INI file" script
> Item. Is this possible?
I fear I do not understand. The above "macros" are used to control the
contents of a text file. file:// instructs the compiler to read (at compile
time) the license agreement from a file and links it into the installer --
local:// instructs the installer to read (at runtime) the license agreement
from an existing file located on the target machine (the compiler does not
link that file into the installer). A preeprocessor (e.g. "#get ini...") is
always executed at compile time, never at installer runtime.
HTH,
Friedrich
NewsArchive
12-08-2009, 09:41 AM
Thanks for your patience, Friedrich. I hope, I could explain my idea
with the attached pdf.
Markus
NewsArchive
12-08-2009, 09:42 AM
Hi Markus,
> Thanks for your patience, Friedrich. I hope, I could explain my idea
> with the attached pdf.
Aha, okay.
local:// is definitely not be possible, but perhaps there is a way to add
file:// macro processing to read the contents of an INI file at compile time
(it's not not an easy task to implement it). We'll investigate it later
this week (at the moment there are more than 400 minor and major feature
requests on the wish-list).
Friedrich
NewsArchive
12-08-2009, 09:42 AM
Update: we checked the compiler source codes and it should be possible to
add file:// macro processing to the "Edit INI File..." function.
Friedrich
NewsArchive
12-08-2009, 09:42 AM
Great!
Markus Zander
NewsArchive
12-08-2009, 09:43 AM
>
> Great!
>
Added. All the functionality was already there and we only had to teach the
compiler how to use the file:// macro.
Friedrich
NewsArchive
12-11-2009, 04:00 AM
Just a thought about your "Third"...
Could you use "Handle Text File Operation" to loop through the INI file as
if it were a .TXT file, and then you could delete any line that doesn't
begin with your list of known settings. It would take a few lines of code,
but should work well.
Thanks,
--Glenn.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.