首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ Builder >

C# 读ini配置文件解决方法

2013-01-02 
C# 读ini配置文件配置文件内容如下[Program1]Timer1081201010202010100010001Timer20000000000000000000

C# 读ini配置文件
配置文件内容如下
[Program1]
Timer1=081201010202010100010001
Timer2=000000000000000000000000
Timer3=000000000000000000000000
Timer4=000000000000000000000000
Timer5=000000000000000000000000
Timer6=000000000000000000000000
Timer7=000000000000000000000000
Timer8=000000000000000000000000
MainScreen=2
Screen=2
[Program1_Screen1]
Position=2048,0,2048,128
ItemCount=0
[Program1_Screen2]
Position=2048,129,2048,127
ItemCount=1
Item1=P,   Test1.r01, 6,6,  5
[Program2]
Timer1=009901120131010700002359
Timer2=000000000000000000000000
Timer3=000000000000000000000000
Timer4=000000000000000000000000
Timer5=000000000000000000000000
Timer6=000000000000000000000000
Timer7=000000000000000000000000
Timer8=000000000000000000000000
MainScreen=1
Screen=1
[Program2_Screen1]
Position=2048,0,2048,256
ItemCount=1
Item1=P,    Test.r01, 8,4,  5
[Program3]
Timer1=081201010202010100010001
Timer2=000000000000000000000000
Timer3=000000000000000000000000
Timer4=000000000000000000000000
Timer5=000000000000000000000000
Timer6=000000000000000000000000
Timer7=000000000000000000000000
Timer8=000000000000000000000000
MainScreen=2
Screen=2
[Program3_Screen1]
Position=2048,0,2048,128
ItemCount=0
[Program3_Screen2]
Position=2048,129,2048,127
ItemCount=1
Item1=P,Test1~00.r01, 6,6,  5
[Program4]
Timer1=009901120131010700002359
Timer2=000000000000000000000000
Timer3=000000000000000000000000
Timer4=000000000000000000000000
Timer5=000000000000000000000000
Timer6=000000000000000000000000
Timer7=000000000000000000000000
Timer8=000000000000000000000000
MainScreen=1
Screen=1
[Program4_Screen1]
Position=2048,0,2048,256
ItemCount=1
Item1=P,Test~~00.r01, 8,4,  5

问题:我用API怎样读取所有的配置信息
[DllImport("kernel32")]
private static extern long WritePrivateProfileString(string section, string key, string val, string filePath);
[DllImport("kernel32")]
private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retVal, int size, string filePath);
配置文件的[Program4]节点可能是N个。
我用过直接用读文件形式来获取。但效率不高。
现请各位大侠帮忙出主意。
[解决办法]
。。。。。。。。。。。sf。。不知道哦·没用过·······

热点排行