CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
不看会后悔的Windows XP之经验谈 简单快捷DIY实用家庭影院
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  VC/MFC >  基础类

请教api函数ReadFile的用法

楼主kenryHuang(冷的时候我想死)2002-02-07 16:11:53 在 VC/MFC / 基础类 提问

抱歉,我没有msdn,没办法查询 问题点数:20、回复次数:4Top

1 楼idAnts(此广告位招租)回复于 2002-02-07 16:20:34 得分 5

http://www.allapi.net/apilist/apifunction.php?apifunction=ReadFileTop

2 楼kenryHuang(冷的时候我想死)回复于 2002-02-07 16:22:41 得分 0

有中文的吗?Top

3 楼pdp(二愣子)回复于 2002-02-07 16:25:52 得分 10

BOOL   ReadFile(  
      HANDLE   hFile,                                 //   handle   to   file  
      LPVOID   lpBuffer,                           //   data   buffer  
      DWORD   nNumberOfBytesToRead,     //   number   of   bytes   to   read  
      LPDWORD   lpNumberOfBytesRead,   //   number   of   bytes   read  
      LPOVERLAPPED   lpOverlapped         //   overlapped   buffer  
  );  
  //   set   up   overlapped   structure   fields    
  gOverLapped.Offset           =   0;    
  gOverLapped.OffsetHigh   =   0;    
  gOverLapped.hEvent           =   hEvent;    
     
  //   attempt   an   asynchronous   read   operation    
  bResult   =   ReadFile(hFile,   &inBuffer,   nBytesToRead,   &nBytesRead,    
          &gOverlapped)   ;    
     
  //   if   there   was   a   problem,   or   the   async.   operation's   still   pending   ...    
  if   (!bResult)    
  {    
          //   deal   with   the   error   code    
          switch   (dwError   =   GetLastError())    
          {    
                  case   ERROR_HANDLE_EOF:    
                  {    
                          //   we're   reached   the   end   of   the   file    
                          //   during   the   call   to   ReadFile    
     
                          //   code   to   handle   that    
                  }    
     
                  case   ERROR_IO_PENDING:    
                  {    
                          //   asynchronous   i/o   is   still   in   progress    
     
                          //   do   something   else   for   a   while    
                          GoDoSomethingElse()   ;    
     
                          //   check   on   the   results   of   the   asynchronous   read    
                          bResult   =   GetOverlappedResult(hFile,   &gOverlapped,    
                                  &nBytesRead,   FALSE)   ;    
     
                          //   if   there   was   a   problem   ...    
                          if   (!bResult)    
                          {    
                                  //   deal   with   the   error   code    
                                  switch   (dwError   =   GetLastError())    
                                  {    
                                          case   ERROR_HANDLE_EOF:    
                                          {    
                                                  //   we're   reached   the   end   of   the   file    
                                                  //during   asynchronous   operation    
                                          }    
     
                                          //   deal   with   other   error   cases    
                                  }    
                          }    
                  }   //   end   case    
     
                  //   deal   with   other   error   cases    
     
          }   //   end   switch    
  }   //   end   if    
  Top

4 楼kiko_lee(清醒的迷茫中)回复于 2002-02-07 16:42:15 得分 5

用法?  
  你直接用   FILE   *fp;  
  open(....);  
  read(...);  
  就可以了吧Top

相关问题

  • API函数GetProfileString的用法
  • 几个API函数用法?
  • 关于API函数PlaySound的用法!
  • 谁知道API函数SetSysColors的用法?
  • 关于API函数Mixeropen的用法
  • 求API函数具体用法
  • 函数用法?
  • SQLConfigDataSource函数用法。
  • AnimateWindow函数用法
  • 请教vb3.0中WindowsFromPoint()API函数的使用法

关键词

  • goverlapped
  • readfile
  • handle
  • read
  • error

得分解答快速导航

  • 帖主:kenryHuang
  • idAnts
  • pdp
  • kiko_lee

相关链接

  • Visual C++类图书
  • Visual C++类源码下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
Copyright © 2000-2008, CSDN.NET, All Rights Reserved
GongshangLogo