Версия для печати темы
Нажмите сюда для просмотра этой темы в оригинальном формате
Форум программистов > C/C++: Системное программирование и WinAPI > Работа с диском


Автор: fanruten 5.6.2006, 14:02
Почему когда я работаю с логическим диском (CreateFile("\\\\.\\i:",....) 
ReadFile не возвращает ошибку даже если я читаю за пределами диска.
 

Автор: MoZy 5.6.2006, 17:08
А нужно, чтоб возвращал? может тогда access подойдет? 

Автор: Damarus 5.6.2006, 18:09
Цитата(MSDN)

ReadFile

The ReadFile function reads data from a file, starting at the position that the file pointer indicates. You can use this function for both synchronous and asynchronous operation. 

The ReadFileEx function is for only asynchronous operation. 

Код

BOOL ReadFile(
  HANDLE hFile,
  LPVOID lpBuffer,
  DWORD nNumberOfBytesToRead,
  LPDWORD lpNumberOfBytesRead,
  LPOVERLAPPED lpOverlapped
);


Return Values
The ReadFile function returns when one of the following conditions occur:

  • A write operation completes on the write end of the pipe.
  • The number of bytes requested is read.
  • An error occurs.


If the function succeeds, the return value is nonzero.

If the function fails, the return value is 0 (zero). To get extended error information, call GetLastError.

If the return value is nonzero and the number of bytes read is 0 (zero), the file pointer is beyond the current end of the file at the time of the read operation. However, if the file is opened with FILE_FLAG_OVERLAPPED and lpOverlapped is not NULL, the return value is 0 (zero) and GetLastError returns ERROR_HANDLE_EOF when the file pointer goes beyond the current end of file.
 

Автор: fanruten 5.6.2006, 18:45
Но почему тогда при работе с физикой я получаю ошибку.

Какие отличая при работе с физикой и логикой помимо возможности доступа к mbr ? 

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)