#Mod .INI's w/WriteProf..
8 messages in this thread
Thanks, Don and Dennis,
Checked out the Windows Programming Reference, and discovered the functions
there. Something interesting, I've noticed though, is the inability to add
a "like" keyname. For instance, I need to add another "device= <blah>"
line in the [386enh] section of a SYSTEM.INI. However, according to the
reference, WritePrivateProfileString only provides for adding if the
specified keyname doesn't exist. Otherwise, it finds the first (if there's
more than one) occurance of the specified keyname and overwrites it with
your specified string.
The only way I can see around this is to add the device I need to add to
the end of an existing "device= " line (i.e. "device = blah.dev, mydevice",
which appears to work).
Any suggestions?
Tom Sollas
There are 2 Replies.
Seems to me that SYSTEM.INI is not a file that is modified a frequently. You
-could- just go ahead and read/write it with normal text file i/o commands.
I won't tell<g>.
– Ricks
There is 1 Reply.
>> I won't tell <g>.
Thanks! <g> My only concern is rumors I've heard about changing the
SYSTEM.INI to a binary format. Would make and ASCII modification useless at
that point…
Tom
There are 2 Replies.
Jeez, a binary format SYSTEM.INI! That would be such a pain in the *ss! I
can't count the times that I have had to undo some entry that a piece of
software installed (ATM, various Shells, Netware, Custom Fonts, etc) or reset
them back. I have several different configuarations (I have a 486 portable)
and rely on software to detect what kind of software configuaration I'm
running with!
I would hope that MS would make the .INI commands a little more powerful to
handle the "device" type keywords, or come up with a new method like
DEVICE1=stuff.sys
DEVICE2=morestuff.sys
ala the PROGMAN.INI file. Also, it seems to me that if any INI <g> goes
binary, then ALL INI files go binary. Hmmm. (I can see that if this is
likely, then there is going to be a slew of INI-EDITORS.)
– Ricks
There is 1 Reply.
I agree that a binary .INI would be somewhat unwieldly, however, I like the
ability to make an API call to change, add (if I only could!!!), or delete
an item. Beats opening, searching, reading and writing an ASCII file…
MS is definately gonna have to come up with a better way to handle multiple
key types, though.
>> INI-Editors
You may have given me a great freeware idea! <gd&r>
Tom Sollas [BDI]
Hi Tom,
WriteProfileString will not add another instance of a keyname such as:
DEVICE=mydevice
DEVICE=yourdevice
To accomplish this, you will need to do the ol'
Open filename For Input #1
Open filename For Output as #2
'
read from one
write to two
delete one
rename two to one
Close
Evidently Windows does this when it need to the same…
Don Funk
There is 1 Reply.
Don,
You're exactly right, that is exactly what I need to do. Here's how I got
around it without opening up an ASCII file (using the API is much easier):
I need:
device=<existing_device> device=<my_new_device>
So I compromised and did:
device=<existing_device>, <my_new_device>
Basically I did a GetPrivateProfileString(..); for the first device
keyname. I then appended ", <my_new_device>" to the end of the string, and
wrote the result back with WritePrivateProfileString(..);
Tom Sollas