[comp.windows.ms] EnumProfileStrings

risto@tuura.UUCP (Risto Lankinen) (09/20/90)

Hi!

There are functions Get/WriteProfileString() in Windows SDK 2.0 and, in
addition, Get/WritePrivateProfileString() in Windows SDK 3.0 .  They work
fine, but to use them, you would need to know either/both of the section
name (which appears in square brackets in corresponding .INI file) and/or
the keyword (which is followed by equal sign and the setting itself).

Now, is there a way to 'Enumerate' either the section names in a particular
.INI file or the keywords under a particular section?  Haven't found one,
except just reading the file and inspecting it on a line-by-line basis
(which I regard extremely inelegant).

I'm also wondering what I *think* I have seen (but could not verify in an
actual installation).  That is, the same keyword more than once under one
section tag (as far as I recall right, the 'windows' section in WIN.INI
has been noticed to list more than one 'device' keywords).  Well, calling
the GetProfileString("AnySection","NonUniqueKeyword",...) returns only
the setting of the first occurrance of more than one.  Wondering how the
others could be read...

Terveisin: Risto Lankinen
-- 
Risto Lankinen / product specialist ***************************************
Nokia Data Systems, Technology Dept *  2                              2   *
THIS SPACE INTENTIONALLY LEFT BLANK * 2 -1 is PRIME!  Now working on 2 +1 *
replies: risto@yj.data.nokia.fi     ***************************************

kensy@microsoft.UUCP (Ken SYKES) (09/23/90)

In article <765@tuura.UUCP> risto@tuura.UUCP (Risto Lankinen) writes:
>Now, is there a way to 'Enumerate' either the section names in a particular
>.INI file or the keywords under a particular section?  Haven't found one,
>except just reading the file and inspecting it on a line-by-line basis
>(which I regard extremely inelegant).
>

You can enumerate the keys in a section by passing NULL for the keyname.
What is returned in the buffer is a list of null-terminated strings.
The end of the list is indicated by an empty string (just the null character)
You won't be able to enumerate the section names without reading win.ini
yourself.

Ken Sykes
Disclaimer: The above opinions are solely my own.