在使用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”文件。