使用来自 kernel32.dll 的 GetPrivateProfileString

Using GetPrivateProfileString from kernel32.dll

我正在开发一个 UWP 应用程序,旨在 运行 在 Raspberry Pi 上。我需要读取存储在 .ini 文件中的数据 - 我知道 Microsoft 希望我使用 xml,但我必须使用 ini.

我已经成功地使用 GetPrivateProfileString(如下:http://www.codeproject.com/Articles/1966/An-INI-file-handling-class-using-C)从带有 "standard" C# 项目的 ini 文件中读取值。

但是,这似乎不适用于 UWP C# 项目。我没有任何错误,只是如果我尝试使用 kernel32 函数读取或写入,则没有任何反应。

发生了什么事?是否仍然可以在 UWP 应用程序中使用这些功能?如果没有,我是否必须自己编写一个 ini 处理程序 class?

MSDN 说:

Note This function is provided only for compatibility with 16-bit Windows-based applications. Applications should store initialization information in the registry.

我假设该功能在您的目标平台上不可用。你必须自己阅读和解析INI文件。