英文:
Where is the file if the Filename parameter is NULL in WritePrivateProfileString
问题
当我使用winbase.h和windows.h来读写.ini文件时,我发现可以使用以下函数成功保存设置:
bool b = WritePrivateProfileStringA("App","key","test", NULL);
但是我找不到这个文件。它在哪里?
另一方面,我可以使用以下代码获取设置:
GetPrivateProfileStringA("App", "key", "default", s, 20,0);
而且它不需要管理员权限来写入文件,所以我认为它应该在用户目录中。
英文:
When I use winbase.h and windows.h to read/write .ini file, I found that I can use the function
bool b = WritePrivateProfileStringA("App","key","test", NULL);
successfully to save the settings.
But I can not found the file. Where is it?
On the other hand, I can use
GetPrivateProfileStringA("App", "key", "default", s, 20,0);
to get the setting.
And it did not need administrator privileges to write the file, so I think it should be in a user directory.
答案1
得分: 0
我找到了。它被写入了Windows注册表的HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\IniFileMapping\win.ini
位置。它包含了应用程序名称的目标路径,不区分大小写。顺便提一下,USR代表的是HKEY_CURRENT_USER。
如果具有管理员权限,它会被写入到C:\Windows\win.ini文件中。
英文:
I found it. It was written to windows registry HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\IniFileMapping\win.ini
It has the destination for appname which is case-insensitive, by the way USR means HKEY_CURRENT_USER.
If it has administrator privileges, it was written to C:\Windows\win.ini
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论