You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Windows 11下WritePrivateProfileString与GetPrivateProfileString API性能变慢问题咨询

Windows 11下WritePrivateProfileString/GetPrivateProfileString API性能下降问题

将Windows桌面应用迁移至Windows 11后,使用WritePrivateProfileString和GetPrivateProfileString API时出现明显性能下降,相同硬件环境下,该应用在Windows 10上的运行速度显著更快。

关键细节

  • Windows 10中,.ini文件的读写操作均非常快速(单次调用通常在1ms内完成)
  • Windows 11中,相同操作耗时明显增加,单次调用有时可达2-3ms甚至更长

写入.ini文件测试代码及结果

通过for循环调用API 10000次进行测试:

CString filePath = L"C:\\path\\to\\myfile.ini";
auto start = std::chrono::high_resolution_clock::now();

for (int i = 0; i < 10000; i++)
{
   section.Format(L"Settings%d", i);
   key.Format(L"Volume%d", i);
   value.Format(L"%d", i);
   WritePrivateProfileString(section, key, value, filePath);
}
auto end = std::chrono::high_resolution_clock::now();
std::chrono::duration<double> duration = end - start;

测试结果:

  • Windows 10:7.93秒
  • Windows 11:12.609秒

读取.ini文件测试代码及结果

同样通过for循环调用API 10000次进行测试:

auto start = std::chrono::high_resolution_clock::now();
for (int i = 0; i < 10000; i++)
{
   section.Format(L"Settings%d", i);
   key.Format(L"Volume%d", i);
   TCHAR buffer[256];
   GetPrivateProfileString(section, key, L"Default", buffer, sizeof(buffer) / sizeof(TCHAR), filePath);
}
auto end = std::chrono::high_resolution_clock::now();
std::chrono::duration<double> duration = end - start;

测试结果:

  • Windows 10:6.72秒
  • Windows 11:10.46秒

已完成的验证操作

  • 确认文件路径与.ini文件有效且可访问
  • 以管理员权限运行应用,排除权限问题影响
  • 使用std::chrono计时,确保时间报告准确

环境信息

  • Windows 10:版本22H2
  • Windows 11:版本23H2
  • 硬件:两个系统使用相同硬件配置
  • 开发环境:Visual Studio 2017(C++)

内容的提问来源于stack exchange,提问作者A Akshatha

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.17 16:12:12