tchar szpath[max_path];
memset(szpath, 0, sizeof(szpath));
getmodulefilename(null, szpath, max_path);
cstring strpath = szpath;
strpath = strpath.left(strpath.reversefind(_t('\\')));
strpath += "\\test_setting.ini";
char exefullpath[max_path] ="";
strncpy_s(exefullpath,max_path,strpath.getbuffer(0), strlen(strpath.getbuffer(0))); //組合出配置檔案的全路徑*/
//讀浮點數
cstring strmm;
getprivateprofilestring(_t("student"),_t("score"),_t("defaultname"),strmmp.getbuffer(100),100,exefullpath);
strmmp.releasebuffer();
double score = atof(strmmp);
//讀整數
int age= getprivateprofileint("student", "age", 0, exefullpath);
//讀文字
getprivateprofilestring("student", "name", "", strmmp.getbuffer(0), 10, exefullpath);
讀配置檔案2
資料 host 1 ip 16.173.234.228 port 21,80,873,3306 cpu 10 freemem 3 conconn 1000 checkgw 1 freedisk 10 swapused 30000 host host 2 ip 16.173.235.25 port 2...
Php讀配置檔案
馬永佔,myz,mayongzhan php讀配置檔案 馬永佔,myz,mayongzhan 要讀的格式 php.ini this is demo by 馬永佔 myz global i 1j 2 k 3 self a 11 b 22 c 33 讀的方法 name test4.php date mo...
Java讀配置檔案
讀取配置檔案的方案 public string getproperty string name,string k in.close catch exception e return val 在springboot中,可以將其設定為aop的切面 注意 第乙個引數name,直接寫a.properties...