c# - 使用 kernel32.dll 中的 GetPrivateProfileString

标签 c# uwp kernel32

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

我已成功使用 GetPrivateProfileString(如下: http://www.codeproject.com/Articles/1966/An-INI-file-handling-class-using-C )通过“标准”C# 项目从 ini 文件中读取值。

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

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

最佳答案

MSDN说:

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

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

关于c# - 使用 kernel32.dll 中的 GetPrivateProfileString,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38498559/

相关文章:

c# - 为什么 MethodImplOptions.Synchronized 在不推荐的情况下导致锁定?

c# - 使用 C# 读取和修改 Microsoft Word 文档

delphi - 如何确定 Delphi 应用程序中终结期间抛出异常的位置?

c# - 如何为 "Auth-Token"的 Web 服务添加 token 认证?

c# - DEP0600 部署 UWP 项目时出错

uwp - 为什么 VisualState Selected 在 listviewitem 中不起作用?

C# UWP : copy file to folder inside local folder not functioning properly

c# - Kernel32.dll 中的 CreateFile 返回无效句柄

winapi - ReadProcessMemory 在某些页面上失败 (GetLastError()=299)

c# - 如何使自定义线程安全通用列表在 C# 中返回整个列表?