在项目中发现,installshield使用FileInsertLine操作文件时会出现乱码的问题,目前没有较好的解决方法,目前采用的方法是对于ini文件,使用专门的ini操作函数来读写则不会出现乱码的情况
以这样一个配置文件为例:
[section1]
key1=value1
key2=value2
[section2]
key1=value1
key2=value2
写ini配置文件:
szFileName = TARGETDIR^"config.ini";
WriteProfString (szFileName ,"section1","key1","valuex");
WriteProfString (szFileName ,"section2","key2","valuex");
2.读ini配置文件:
GetProfString ( szFileName, "section1", "key1", svResult1 );
GetProfString ( szFileName, "section1", "key2", svResult2 );
返回值svResult1和svResult2 对应Feature1和Feature2 对应值。
3.替换ini配置文件的对应键值
ReplaceProfString ( szFileName, "section1", "key1", "value1", "key4" );
ReplaceProfString ( szFileName, "section1", "key2", "value2, "key3" );
网友评论