在使用GetPrivateProfileString时需要注意一点,
DWORD WINAPI GetPrivateProfileString(
_In_ LPCTSTR lpAppName,
_In_ LPCTSTR lpKeyName,
_In_ LPCTSTR lpDefault,
_Out_ LPTSTR lpReturnedString,
_In_ DWORD nSize,
_In_ LPCTSTR lpFileName
);
其参数中
- lpFileName [in]
-
The name of the initialization file. If this parameter does not contain a full path to the file, the system searches for the file in the Windows directory.
当参数不包含文件全路径时,系统会在Windows中寻找该文件,而并不是我们习惯性认为的在当前工作目录下寻找。
当我们以"./test.ini"作为参数传入时,系统会在当前工作目录下读写test.ini文件,但是我们仅为"test.ini"文件作为参数传入时,系统仅会在X:/Windows目录下查找“test.ini”文件。
本文详细介绍了在使用GetPrivateProfileString函数时,如何正确指定INI文件路径的重要性。特别是当仅提供文件名而非完整路径时,系统将在Windows目录而非当前工作目录中搜索文件。
1203

被折叠的 条评论
为什么被折叠?



