新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
VC中讀寫INI文件
在VC2015中讀寫INI文件,文件以ANSI格式保存,如果以UTF-8保存,可能會產(chǎn)生亂碼。
創(chuàng)新互聯(lián)專注于成都做網(wǎng)站、網(wǎng)站建設、外貿營銷網(wǎng)站建設、網(wǎng)頁設計、網(wǎng)站制作、網(wǎng)站開發(fā)。公司秉持“客戶至上,用心服務”的宗旨,從客戶的利益和觀點出發(fā),讓客戶在網(wǎng)絡營銷中找到自己的駐足之地。尊重和關懷每一位客戶,用嚴謹?shù)膽B(tài)度對待客戶,用專業(yè)的服務創(chuàng)造價值,成為客戶值得信賴的朋友,為客戶解除后顧之憂。
LPCTSTR strfile = _T(".//config.ini"); TCHAR value[255] = { 0 }; //讀鍵值 GetPrivateProfileString( _T("ui"), _T("button1"), _T("default"), value, 200, strfile); //寫鍵值對 WritePrivateProfileString(_T("UI"), _T("button1"), _T("啟動"), strfile); //讀整數(shù) int left = GetPrivateProfileInt(_T("UI"), _T("left"), 0, strfile); CString strleft; strleft.Format(_T("%d"),left); //讀出某節(jié)的所有鍵值對 TCHAR chSection[1000]; GetPrivateProfileSection(_T("UI"), chSection, 200, strfile); CStringArray list; int len; TCHAR *pBuf = chSection; while ((len = wcslen(pBuf)) > 0) { list.Add(pBuf); pBuf += len + 1; } //讀出某節(jié)的所有鍵名 TCHAR chSectionName[1000]; GetPrivateProfileSectionNames(chSectionName, 200, strfile); CStringArray list1; int len1; TCHAR *pBuf1 = chSectionName; while ((len1 = wcslen(pBuf1)) > 0) { list1.Add(pBuf1); pBuf1 += len1 + 1; }
文章標題:VC中讀寫INI文件
文章來源:http://ef60e0e.cn/article/posgej.html