读写ini配置文件时的相对路径问题
2014-07-03 19:06
393 查看
在使用GetPrivateProfileString时需要注意一点,
其参数中
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”文件。
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”文件。
相关文章推荐
- java jar 配置文件的相对路径问题
- Spring读取配置文件,地址问题,绝对路径,相对路径
- 相对路径读写配置文件
- QT读写ini配置文件以及绝对路径的使用
- JAVA随笔篇三(读写Properties配置文件以及路径问题详解)
- 设置php在apache下加载ini配置文件路径,~和curl扩展无法加载的问题
- qt配置文件读写及路径设置,ini语法
- 关于Win7系统中软件安装目录下ini配置文件的读写问题
- Asp.Net中使用Access数据库配置文件使用相对路径问题
- C#中读写INI配置文件
- vc里读取配置文件(ini)的问题
- log4j中配置日志文件相对路径方法分析
- WinMoblie 利用EVC读写INI,XML配置文件
- 用java读写ini配置文件(转)
- 用API读写INI配置文件
- 如何用VFP读写配置文件(.INI)?
- C#中读写INI配置文件
- [转]用C#读写ini配置文件
- log4j中配置日志文件相对路径
- 用C#读写ini配置文件