Are comments allowed in Windows ini files? (…assuming you're using the GetPrivateProfileString api functions to read them…)
[Section]
Name=Value ; comment
; full line comment
And, is there a proper spec of the .INI file format anywhere?
Thanks for the replies – However maybe I wasn't clear enough. It's only the format as read by Windows API Calls that I'm interested in. I know other implementations allow comments, but it's specifically the MS Windows spec and implementation that I need to know about.
Best Answer
Windows INI API support for:
;
The authoritative source is the Windows API function that reads values out of INI files
The reason "full line comments" work is because the requested value does not exist. For example, when parsing the following
ini
file contents:Reading the values:
UseLiveData
:1
coke
: not present;coke
: not presentpepsi
:diet ;gag
stackoverflow
: not present#stackoverflow
:splotchy
Update: I used to think that the number sign (#) was a pseudo line-comment character. The reason using leading # works to hide
stackoverflow
is because the namestackoverflow
no longer exists. And it turns out that semi-colon (;
) is a line-comment.But there is no support for trailing comments.