Get all the sections and keys in the INI file and deposit them into the vector as pair
1#include <iostream>2#include <windows.h>3#include <string>4#include <vector>5 using namespacestd;6 7 #definePATH "E:\\vc_code\\parse_ini\\cfg.ini"8 intMain ()9 {Ten Charbuff[1024x768] = {0}; Onevector<string>vecsections; Avector<string>Veckeys; -vector<pair<string,string>>Vecsectionkey; - intnum = getprivateprofilesectionnames (buff,1024x768, PATH); thesize_t startpos =0; - for(size_t i =0; i < num; ++i) - { - if(' /'==Buff[i]) + { - stringTMP (buff + startpos, Buff +i); +startpos = i +1; A Vecsections.push_back (TMP); at } - } - - for(size_t i =0; I < vecsections.size (); ++i) - { - Charbuffkey[1024x768] = {0}; innum = Getprivateprofilesection (Vecsections[i].c_str (), Buffkey,1024x768, PATH); -Startpos =0; to for(size_t j =0; J < num; ++j) + { - if(' /'==Buffkey[j]) the { * stringTMP (Buffkey + startpos, Buffkey +j); $Startpos = j +1;Panax Notoginsengsize_t pos = Tmp.find ('='); -Veckeys.push_back (Tmp.substr (0, POS)); the +Vecsectionkey.push_back (Make_pair (Vecsections[i], tmp.substr (0, POS) )); A } the } + } - $ return 0; $}
View Code
Get INI file all the sections and keys