
[此贴子已经被作者于2004-11-20 17:54:11编辑过]
; //读字符串 long GetProfileLong(char *pStrSegment,char *pStrKey,long lDefault=0L);//读32位整数 WORD GetProfileWord(char *pStrSegment,char *pStrKey,WORD wDefault);//读16位无符号整数 int GetProfileInt(char *pStrSegment,char *pStrKey, int nDefault);//读16位有符号整数 float GetProfileFloat(char *pStrSegment,char *pStrKey,float fDefault);//读单精度浮点数 double GetProfileDouble(char *pStrSegment,char *pStrKey,double dbDefault);//读双精度浮点数 //写键值 BOOL WriteProfileString(char *pStrSegment,char *pStrKey,char *pStrDefault);//写字符串 BOOL WriteProfileLong(char *pStrSegment,char *pStrKey,long lDefault);//写32位有符号整数 BOOL WriteProfileWord(char *pStrSegment,char *pStrKey,WORD wDefault);//写16位无符号整数 BOOL WriteProfileInt(char *pStrSegment,char *pStrKey, int nDefault);//写16位于符号整数 BOOL WriteProfileFloat(char *pStrSegment,char *pStrKey,float fDefault);//写单精度浮点数 BOOL WriteProfileDouble(char *pStrSegment,char *pStrKey,double dbDefault);//写双精度浮点数3:使用举例#include “Symbol.h”#include “Register.h”BOOL MySample_27(){CRegister* pRegister = new CRegister("Config.Ini"
; //加载文件if (pRegister == NULL || NULL == pRegister->GetFile()) //判断是否加载成功{ DELETE(pRegister); return(FALSE);}//读一整数int nHello = pRegister->GetProfileInt(” Boot”, “Hello”, 37);//读一无符号整数int nSign = pRegister->GetProfileInt(” Boot”, “Sign”, 37u);//读一长整数long lgGood = pRegister->GetProfileLong(” Boot”, “Good”, 37L);//读单精度浮点数float fData = pRegister->GetProfileFloat(” Boot”, ”LiPing”, 0.5f);//读双精度浮点数double dbData = pRegister->GetProfileDouble(” Boot”, ”Line4”, 3.7);//读布尔变量BOOL bBoolV = pRegister->IsProfileBoolen(pRegister->GetProfileString(“Boot”,”BootV”,”True”));//读字符串char strPrintName[256];_fstrcpy(strPrintName, pRegister->GetProfileString(” Boot”, “Print”, “LPT1”)); //写一整数pRegister->WriteProfileInt(” Boot”, “Hello”, nHello);//写一无符号整数pRegister->WriteProfileInt(” Boot”, “Sign”, nSign);//写一长整数pRegister->WriteProfileLong(” Boot”, “Good”, lgGood);//写单精度浮点数pRegister->WriteProfileFloat(” Boot”, ”LiPing”, fData);//写双精度浮点数pRegister->WriteProfileDouble(” Boot”, ”Line4”, dbData);//写布尔变量pRegister->WriteProfileString(“Boot”,”BootV”,((bBoolV)?”True”:”False”));//写字符串pRegister->WriteProfileString(” Boot”, “Print”, strPrintName); delete pRegister;}| Quote: | |
|
;


| Quote: | |
|
| Quote: | |
|
| 欢迎光临 中国DOS联盟论坛 (http://cndos.fam.cx/forum/) | Powered by Discuz! 2.5 |