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.
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.
USE A SEMI-COLON AT BEGINING OF LINE --->> ; <<---
Ex.
I have seen comments in INI files, so yes. Please refer to this Wikipedia article. I could not find an official specification, but that is the correct syntax for comments, as many game INI files had this as I remember.
Edit
The API returns the Value and the Comment (forgot to mention this in my reply), just construct and example INI file and call the API on this (with comments) and you can see how this is returned.
Yes. Have a look at Wikipedia and Cloanto Implementation of INI File Format (see bottom of page).