请教api函数ReadFile的用法
抱歉,我没有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




