| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1358 人关注过本帖
标题:怎么用MFC实现保存功能
取消只看楼主 加入收藏
gyp277953394
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2011-4-18
结帖率:0
收藏
已结贴  问题点数:10 回复次数:0 
怎么用MFC实现保存功能
我想编辑一个按钮让这个按钮能保存编辑框中的文字,现在知道能用CFile类,但是具体的代码看不明白
   HANDLE hFile = CreateFile(_T("D:\\MyFile.DAT"),
         GENERIC_WRITE, FILE_SHARE_READ,
         NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);

   if (hFile == INVALID_HANDLE_VALUE)
      AfxMessageBox(_T("Couldn't create the file!"));
   else
   {
      // Attach a CFile object to the handle we have.
       CFile myFile(hFile);

      static const char sz[] = "Hockey is best!";

      // write string, without null-terminator
      myFile.Write(sz, lstrlen(sz));

      // We can call Close() explicitly, but the destructor would have
      // also closed the file for us. Note that there's no need to
      // call the CloseHandle() on the handle returned by the API because
      // MFC will close it for us.
      myFile.Close();
   }
请高手们指教
搜索更多相关主题的帖子: 编辑 
2011-04-18 10:24
快速回复:怎么用MFC实现保存功能
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.019071 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved