flat assembler
Message board for the users of flat assembler.

Index > Windows > reading ini files

Author
Thread Post new topic Reply to topic
Ali.Z



Joined: 08 Jan 2018
Posts: 716
Ali.Z 12 Feb 2018, 09:53
so i have an opened handle to a file, got it by CreateFile.

however using ReadFile will read from the beginning of the file, while i dont want that .. i wanna read from specific row/columns only.

actually its .ini file, so im not sure how to achieve that.
thanks in advance.

_________________
Asm For Wise Humans
Post 12 Feb 2018, 09:53
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20302
Location: In your JS exploiting you and your system
revolution 12 Feb 2018, 10:16
Since is is just plain text with no defined structure, you will have parse the file line-by-line or byte-by-byte.

But Windows does have API calls to read/write ini files. But be careful using them because Windows likes to copy them into the registry and expects you to delete the file.
Post 12 Feb 2018, 10:16
View user's profile Send private message Visit poster's website Reply with quote
Furs



Joined: 04 Mar 2016
Posts: 2493
Furs 12 Feb 2018, 12:58
revolution wrote:
But be careful using them because Windows likes to copy them into the registry
That's news to me. Such bad behavior, since when?
Post 12 Feb 2018, 12:58
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20302
Location: In your JS exploiting you and your system
revolution 12 Feb 2018, 13:31
Furs wrote:
revolution wrote:
But be careful using them because Windows likes to copy them into the registry
That's news to me. Such bad behavior, since when?
Since always AFAIK.
The system maps most .ini file references to the registry, using the mapping defined under the following registry key:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\IniFileMapping
Post 12 Feb 2018, 13:31
View user's profile Send private message Visit poster's website Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2341
Location: Usono (aka, USA)
rugxulo 12 Feb 2018, 19:39
What about inih?

Quote:

inih (INI Not Invented Here) is a simple .INI file parser written in C. It's only a couple of pages of code, and it was designed to be small and simple, so it's good for embedded systems. It's also more or less compatible with Python's ConfigParser style of .INI files, including RFC 822-style multi-line syntax and name: value entries.
Post 12 Feb 2018, 19:39
View user's profile Send private message Visit poster's website Reply with quote
Ali.Z



Joined: 08 Jan 2018
Posts: 716
Ali.Z 13 Feb 2018, 06:25
GetPrivateProfileString - GetPrivateProfileInt

thanks rev for sharing the link, if i understood these functions well .. then i think this is what i need.
to read string and integer.

thanks again rev.
Post 13 Feb 2018, 06:25
View user's profile Send private message Reply with quote
Furs



Joined: 04 Mar 2016
Posts: 2493
Furs 13 Feb 2018, 13:24
revolution wrote:
Since always AFAIK.
Eek. Never had it happen on "private" inis (not system ones) but the doc does say it could also be "copied", so that's bad. There goes more useful APIs to the trashbin, sigh (and the reason people use private .ini files is because they want to make a portable app, not CENTRALIZED settings bullshit like the registry).
Post 13 Feb 2018, 13:24
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20302
Location: In your JS exploiting you and your system
revolution 13 Feb 2018, 14:18
Furs wrote:
revolution wrote:
Since always AFAIK.
Eek. Never had it happen on "private" inis (not system ones) but the doc does say it could also be "copied", so that's bad. There goes more useful APIs to the trashbin, sigh (and the reason people use private .ini files is because they want to make a portable app, not CENTRALIZED settings bullshit like the registry).
I've always avoided the ini handling APIs and done my own parsing. Because otherwise I could never feel sure which setting is taking precedence, the file or the registry. Especially when external tools, like a simple text editor, could be used to edit the ini file and it gets out of sync with the copy that Windows has.
Post 13 Feb 2018, 14:18
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.