Do standard .ini files allow.

Are comments allowed in ini files for Windows? (... assuming you are using the GetPrivateProfileString api function to read them ...)

[Section] Name=Value ; comment ; full line comment 

And is there a suitable .INI format somewhere?

Thanks for answers. However, perhaps I was not clear enough. This is the only format that is readable in the Windows API Calls that interests me. I know that other implementations allow comments, but this is specifically the specification and implementation of MS Windows that I need to know about.

+44
comments windows ini
Sep 04 '09 at 9:42
source share
3 answers

I saw comments in INI files, so yes. Please refer to this Wikipedia article . I could not find the official specification, but this is the correct syntax for comments, since many INI game files had this, as I recall.

Edit

The API returns a value and a comment (forgot to mention it in his answer), just create an example INI file and call the API on this (with comments), and you will see how it returns.

+21
Sep 04 '09 at 9:45
source share

Windows INI API support for:

  • Comments on the line : yes (using a colon ; )
  • Tracking Comments: No

The authoritative source is the Windows API function, which reads values ​​from INI files.

GetPrivateProfileString

Retrieves a string from the specified section in the initialization file.

The reason the "full comment line" works is because the requested value does not exist. For example, when analyzing the following contents of an ini file:

 [Application] UseLiveData=1 ;coke=zero pepsi=diet ;gag #stackoverflow=splotchy 

Reading values:

  • UseLiveData : 1
  • coke : no
  • ;coke : no
  • pepsi : diet ;gag
  • stackoverflow : no
  • #stackoverflow : splotchy

Refresh . I used to think that the sign of the number (#) was a symbol of a pseudo-command. The reason that # is used to hide stackoverflow is because the name stackoverflow no longer exists. And it turns out that the semicolon ( ; ) is the comment line.

But support for trailing comments is not supported.

+37
Oct 23 '13 at 18:55
source share

Yes. See Wikipedia and Cloanto Implementing the INI File Format (see bottom of page).

0
Sep 04 '09 at 9:45
source share



All Articles