怎麼獲得INI檔案的節數,鍵名數,鍵數

2021-06-19 03:49:15 字數 2261 閱讀 4540

//the buffer for "string" or "sectionnames" return 

cstring cinientry::getstring(lpctstr lpinifilename,lpctstr lpsectionname, lpctstr lpkeyname)

bool cinientry::writestring(lpctstr lpinifilename, lpctstr lpsectionname, lpctstr lpkeyname, lpctstr lpstring)

cstring cinientry::enumsectionnames(lpctstr lpinifilename,char chspacesign)

return "";

}cstring cinientry::getsection(lpctstr lpinifilename, lpctstr lpsectionname,char chspacesign)

return "";

}cstring cinientry::enumkeys(lpctstr lpinifilename, lpctstr lpsectionname,char chspacesign)

return kn;

}return "";

}

------解決方案--------------------

#define max_buffer	1024	//the buffer for "string" or "sectionnames" return 

cstring cinientry::getstring(lpctstr lpinifilename,lpctstr lpsectionname, lpctstr lpkeyname)

bool cinientry::writestring(lpctstr lpinifilename, lpctstr lpsectionname, lpctstr lpkeyname, lpctstr lpstring)

cstring cinientry::enumsectionnames(lpctstr lpinifilename,char chspacesign)

return "";

}cstring cinientry::getsection(lpctstr lpinifilename, lpctstr lpsectionname,char chspacesign)

return "";

}cstring cinientry::enumkeys(lpctstr lpinifilename, lpctstr lpsectionname,char chspacesign)

return kn;

}return "";

}

------解決方案-------------------- 遍歷一遍就可以了吧 ------解決方案-------------------- ------解決方案-------------------- getprivateprofilesection/getprivateprofilesectionnames  ------解決方案-------------------- 如果ini是自己寫的,總數還是自己搞個鍵數統計一下。 api沒有直接提供介面,要自己遍歷和解析。 ------解決方案--------------------

#define max_section 1000//section的最大字長度

wchar_t filetemp[max_path + 1];

::getcurrentdirectory(max_path,filetemp);//取當前路徑

wcscat(filetemp,l"\\setup.ini");//配置檔案

wchar_t configstr[max_section + 1];

dword sectionnum = getprivateprofilestring(null,null,l"",configstr,max_section,filetemp);//讀取所有的section儲存,section之間用null隔開

int posnum = 0;//標記遍歷字串時null的位置

wchar_t *temp = configstr + posnum;

for(posnum; posnum < sectionnum;)//configstr以兩個null作為結束

**不好,莫笑

引用:

如果ini是自己寫的,總數還是自己搞個鍵數統計一下。

api沒有直接提供介面,要自己遍歷和解析。

INI檔案的操作

概述 在程式中經常要用到設定或者其他少量資料的存檔,以便程式在下一次執行的時候可以使用,比如說儲存本次程式執行時視窗的位置 大小 一些使用者設定的資料等等,在 dos 下程式設計的時候,我們一般自己產生乙個檔案,由自己把這些資料寫到檔案中,然後在下一次執行的時候再讀出來使用。在 win32 程式設計...

ini檔案的讀寫

1.function readstring const section,ident,default string string 函式中section為節點名,ident為關鍵字,default為預設值.procedure writestring const section,ident,default...

ini 檔案的讀寫

strfilename ini檔名 strsection 節名稱 strkey 鍵名 strvalue 鍵值 public function iniwritekey strfilename as string,strsection as string,strkey as string,strvalu...