用sdk做的软件,想保存一些程序数据,设置。不用 ini 或 xml,用API的ReadFile和WriteFile。需要:
⒈ 直接读取相应的设置,比如:通过"Version"读取1.0.0.1;通过AutoRun读取1。
⒉ 读取提醒,并可删除,排序。
⒊ 效率高(内存映射文件是否比直接读取要快呢?)。如果有用 STL 完成的类也行。请给个现成的类好吗?拜托了!邮件:[email protected]
⒈ 直接读取相应的设置,比如:通过"Version"读取1.0.0.1;通过AutoRun读取1。
⒉ 读取提醒,并可删除,排序。
⒊ 效率高(内存映射文件是否比直接读取要快呢?)。如果有用 STL 完成的类也行。请给个现成的类好吗?拜托了!邮件:[email protected]
可以用GetPrivateProfileString(),GetProfileString(),GetProfileString(),GetProfileInt()来读取。
用.dat的话只有用文件的输入输出流来做,不过有些麻烦,读取->比较这个过程应该就差不多了吧
const char* file_name = "test.dat";
std::ifstream file_in(file_name);
if (!file_in) {
std::cerr << "** Error: could not open file " << dep_file_name
<< std::endl;
return -1;
}
string str;
int n;
char ch;
file >> str;
file >> n;
file >> ch;
CArchive ar(&hfile,Carchive::store);
CString str;
ar<<str;
ar.Flush();
ar.Close();
hfile.Close();
不用ini,是不想让数据用文本编辑器都能看到,而且很容易被用户修改。
用dat,则不存在这样的问题。
cfo.Open
cfo.Write
cfo.Close