Home > Archive > Visual Basic > August 2005 > .ini file standards?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
.ini file standards?
|
|
| MSingAste 2005-08-24, 6:55 pm |
| Hello. Are there documented standards for valid strings for
WritePrivateProfileString(), etc.? All I could find was that a section in the
initialization file must have the following form:
[section]
key=string
Specifically I was wondering:
1. Can a string itself contain brackets ([]), or is that reserved for
sections?
2. Can a string contain an equals sign, eg. "key=Value=foo"?
3. Must a section begin on its own line, and at the first position?
I know I could code around all of these questions, but I'd like to know what
the standard is.
TIA,
Michael
| |
|
|
"MSingAste" <MSingAste@discussions.microsoft.com> wrote in message
news:5D27D17A-0476-4077-8B4A-7A74C75D3517@microsoft.com...
> Hello. Are there documented standards for valid strings for
> WritePrivateProfileString(), etc.? All I could find was that a section in
the
> initialization file must have the following form:
>
> [section]
> key=string
>
> Specifically I was wondering:
> 1. Can a string itself contain brackets ([]), or is that reserved for
> sections?
>
Yes if in a quoted string
>
> 2. Can a string contain an equals sign, eg. "key=Value=foo"?
>
Yes, if in a quoted string.
>
> 3. Must a section begin on its own line, and at the first position?
>
Yes, not sure if it can be spaced over or not.
>
> I know I could code around all of these questions, but I'd like to know
what
> the standard is.
>
> TIA,
>
> Michael
I am having touble locating MS's archive page on the exact rules. (But there
aren't many)
Something else - you can use the semicolon to 'remark-out' and entry or add
a comment.
Unfortunately, the Write APIs are not very good at respecting their
positions.
[JUNK]
;Use the following key to stop
stop=yes
;usesless_old_key="twee"
| |
|
|
"MSingAste" <MSingAste@discussions.microsoft.com> wrote in message
news:5D27D17A-0476-4077-8B4A-7A74C75D3517@microsoft.com...
> Hello. Are there documented standards for valid strings for
> WritePrivateProfileString(), etc.? All I could find was that a section in
the
> initialization file must have the following form:
>
> [section]
> key=string
>
> Specifically I was wondering:
> 1. Can a string itself contain brackets ([]), or is that reserved for
> sections?
> 2. Can a string contain an equals sign, eg. "key=Value=foo"?
> 3. Must a section begin on its own line, and at the first position?
>
> I know I could code around all of these questions, but I'd like to know
what
> the standard is.
>
> TIA,
>
> Michael
Here is an interesting link:
http://cloanto.com/specs/ini.html
| |
| MSingAste 2005-08-25, 3:55 am |
| I had seen this page when I was googling for an answer, but I'd like
something straight from the horses's (ok, Microsoft's) mouth.
Thanks again,
Michael
"Ralph" wrote:
>
> "MSingAste" <MSingAste@discussions.microsoft.com> wrote in message
> news:5D27D17A-0476-4077-8B4A-7A74C75D3517@microsoft.com...
> the
> what
>
> Here is an interesting link:
> http://cloanto.com/specs/ini.html
>
>
>
| |
|
|
"MSingAste" <MSingAste@discussions.microsoft.com> wrote in message
news:1CBB6F04-0457-470C-8F09-7B931BA7FA82@microsoft.com...[color=darkred]
> I had seen this page when I was googling for an answer, but I'd like
> something straight from the horses's (ok, Microsoft's) mouth.
>
> Thanks again,
>
> Michael
>
> "Ralph" wrote:
>
in[color=darkred]
know[color=darkred]
I hear you. You got my curiosity up so I went looking. I remember reading,
seeing something, but at my age it gets tough because I often can't remember
if it was last year or twenty-years ago. I couldn't find a thing at the MSDN
site. So when I found that article, I thought it was a good summary of
everything I remembered.
Also note the article talked about a definition from Windows for Workgroups
(that bizzare hybrid). Here is that documentation:
http://www.microsoft.com/technet/ar...kit/26_ini.mspx
When Win95 was released the march was already on from .ini files to the
Registry. WritePrivateProfile no longer wrote to an .ini by default. There
doesn't appear to any Win3.0 material left.
All other references at MSDN appear to describe only the format for specific
uses, ie, the P&D package script, the ADO Schema file, VSS configuration,
etc.
Good luck.
-ralph
| |
| Karl E. Peterson 2005-08-25, 6:55 pm |
| MSingAste wrote:
> I had seen this page when I was googling for an answer, but I'd like
> something straight from the horses's (ok, Microsoft's) mouth.
Heh, and you think *if* they set a standard they'd follow it? <g> (Said recalling
the multiple device= lines in system.ini!)
--
Working Without a .NET?
http://classicvb.org/petition
| |
| Douglas J. Steele 2005-08-27, 7:55 am |
| Write a quick test to determine the answers. Who cares whether or not you
find the stuff documented as long as you can make it work!
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)
"MSingAste" <MSingAste@discussions.microsoft.com> wrote in message
news:5D27D17A-0476-4077-8B4A-7A74C75D3517@microsoft.com...
> Hello. Are there documented standards for valid strings for
> WritePrivateProfileString(), etc.? All I could find was that a section in
> the
> initialization file must have the following form:
>
> [section]
> key=string
>
> Specifically I was wondering:
> 1. Can a string itself contain brackets ([]), or is that reserved for
> sections?
> 2. Can a string contain an equals sign, eg. "key=Value=foo"?
> 3. Must a section begin on its own line, and at the first position?
>
> I know I could code around all of these questions, but I'd like to know
> what
> the standard is.
>
> TIA,
>
> Michael
| |
| Tom Esh 2005-08-27, 6:55 pm |
| On Sat, 27 Aug 2005 05:51:08 -0400, "Douglas J. Steele"
<NOSPAM_djsteele@NOSPAM_canada.com> wrote:
>Write a quick test to determine the answers. Who cares whether or not you
>find the stuff documented as long as you can make it work!
You would ....if you wanted to be sure it didn't break unexpectedly:-)
-Tom
MVP - Visual Basic
(please post replies to the newsgroup)
| |
|
| MSingAste wrote:
> Hello. Are there documented standards for valid strings for
> WritePrivateProfileString(), etc.? All I could find was that a section in the
> initialization file must have the following form:
>
> [section]
> key=string
>
> Specifically I was wondering:
> 1. Can a string itself contain brackets ([]), or is that reserved for
> sections?
> 2. Can a string contain an equals sign, eg. "key=Value=foo"?
> 3. Must a section begin on its own line, and at the first position?
>
> I know I could code around all of these questions, but I'd like to know what
> the standard is.
>
> TIA,
> Michael
http://www.google.com/url?sa=t&ct=r...MBpXAigG3u6mlCg
WritePrivateProfileString
.....
BOOL WritePrivateProfileString(
LPCTSTR lpAppName,
LPCTSTR lpKeyName,
LPCTSTR lpString,
LPCTSTR lpFileName
);
Parameters
lpAppName
[in] Pointer to a null-terminated string containing the name of the
section to which the string will be copied. If the section does not
exist, it is created. The name of the section is case-independent; the
string can be any combination of uppercase and lowercase letters.
lpKeyName
[in] Pointer to the null-terminated string containing the name of
the key to be associated with a string. If the key does not exist in the
specified section, it is created. If this parameter is NULL, the entire
section, including all entries within the section, is deleted.
lpString
[in] Pointer to a null-terminated string to be written to the file.
If this parameter is NULL, the key pointed to by the lpKeyName parameter
is deleted.
Windows Me/98/95: The system does not support the use of the
TAB (\t) character as part of this parameter.
lpFileName
[in] Pointer to a null-terminated string that specifies the name of
the initialization file.
If the file was created using Unicode characters, the function
writes Unicode characters to the file. Otherwise, the function writes
ANSI characters.
Return Values
If the function successfully copies the string to the initialization
file, the return value is nonzero.
If the function fails, or if it flushes the cached version of the most
recently accessed initialization file, the return value is zero. To get
extended error information, call GetLastError.
Remarks
A section in the initialization file must have the following form:
[section]
key=string
.....
Mike
| |
|
| MSingAste wrote:
> Hello. Are there documented standards for valid strings for
> WritePrivateProfileString(), etc.? All I could find was that a section in the
> initialization file must have the following form:
>
> [section]
> key=string
>
> Specifically I was wondering:
> 1. Can a string itself contain brackets ([]), or is that reserved for
> sections?
> 2. Can a string contain an equals sign, eg. "key=Value=foo"?
> 3. Must a section begin on its own line, and at the first position?
> I know I could code around all of these questions, but I'd like to know what
> the standard is.
> TIA,
> Michael
This might be worth a look too.
http://cloanto.com/specs/ini.html
Mike
| |
| MSingAste 2005-08-30, 6:55 pm |
| Thanks to all who replied. The reason I was looking for a documented standard
is that our own product's parser was not handling brackets as part of a
value. I wanted to know if it was reasonable to assume that if we encountered
a [ in the middle of the line then it was not a section header. I didn't want
to break any client's existing code.
Anyway, I found a sample at
http://www.officecomputertraining.c...ages/page40.asp which
allowed me to test the behavior with VB. This confirmed that brackets can be
part of the value string and that, while the section header does not need to
be in the line's first position, it has to be the first non-whitespace
character to be read as a section header.
Thanks again,
Michael
"MSingAste" wrote:
> Hello. Are there documented standards for valid strings for
> WritePrivateProfileString(), etc.? All I could find was that a section in the
> initialization file must have the following form:
>
> [section]
> key=string
>
> Specifically I was wondering:
> 1. Can a string itself contain brackets ([]), or is that reserved for
> sections?
> 2. Can a string contain an equals sign, eg. "key=Value=foo"?
> 3. Must a section begin on its own line, and at the first position?
>
> I know I could code around all of these questions, but I'd like to know what
> the standard is.
>
> TIA,
>
> Michael
|
|
|
|
|