具有重复键的 INI 文件 [英] INI File With Duplicate Keys

查看:39
本文介绍了具有重复键的 INI 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有一个像这样的 INI 文件:

Say I have an INI file like so:

[123]
name=Ryan
name=Joe

我将如何使用诸如 GetPrivateProfileSectionGetPrivateProfileString?

How would I retrieve "name=Ryan\nname=Joe" using API calls such as GetPrivateProfileSection and GetPrivateProfileString?

推荐答案

是的,GetPrivateProfileSection 会返回它.GetPrivateProfileString() 显然只能检索Ryan".您不会像您想要的那样将字符串交给您,名称/值对由零分隔.列表的末尾由两个零表示.您在解析它时需要考虑到这一点.

Yes, GetPrivateProfileSection will return it. GetPrivateProfileString() can obviously only ever retrieve "Ryan". You won't get the string handed to you like you want, the name/value pairs are separated by a zero. The end of the list is indicated by two zeros. You'll need to account for that when you parse it.

这篇关于具有重复键的 INI 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆