请教磁盘扇区读写的一些问题!!!(290分)

  • 主题发起人 主题发起人 stuwei
  • 开始时间 开始时间
S

stuwei

Unregistered / Unconfirmed
GUEST, unregistred user!
请教磁盘扇区读写的一些问题!!!<br>1,磁盘的扇区数和磁道数的获取方法<br>2,对磁盘指定扇区的读、写操作的方法<br>&nbsp;求相关的API函数,最好有例子说明
 
http://askpro.east.net.cn/cgi-bin/view.pl?002045
 
找不到答案<br>请版主帮我回收分数吧!
 
Window下是不让你直接读磁盘的,如果要读会比较麻烦,<br>干么不在DOS下写这类的程序?
 
收回分数?<br>我们大家都不知扔了多少了,还收回?<br>————————————————————————————<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 后悔当初不少放分
 
取得磁盘扇区,磁道信息,GetDiskFreeSpace<br><br>Win2000下直接读写磁盘扇区  作者 N/A<br>在NT和2000下,通过CreateFile来打开需要读写的驱动器,ReadFile、WriteFile来进行磁盘读写。<br><br>下面的代码演示了,如何读写A驱<br><br>/* -----------------------------------------------------<br><br>Read Floppy Disk Sector for win NT/2000<br>reads [numsec] sectors from [head] [track] [sector]<br><br>-------------------------------------------------------*/<br><br><br>char* ReadSectors(int head, int sector, int track, int numsec)<br>{<br><br><br>// getting logical sector from absolute head/track/sector ...<br>//计算扇区位置<br>int LogicalSector = (sector-1) +<br>(head*SECTORSPERTRACK) +<br>(track*SECTORSPERTRACK*NUMOFHEADS) ;<br><br>char *buffer ;<br>HANDLE hDevice ;<br><br><br>HANDLE hDevice;<br>char* buffer = (char*)malloc (512*numsec);<br>strset ( buffer , ' ');<br>DWORD bytesread ;<br><br>// getting a handle to the drive a: using<br>// CreateFile () function ....<br>//打开驱动器 //./A:<br>hDevice = CreateFile("////.//A:",<br>GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,<br>NULL, OPEN_EXISTING, 0, NULL);<br><br>if (hDevice == NULL)<br>{<br>MessageBox ("Failed !");<br>return NULL;<br>}<br><br><br>// setting the file pointer to the start of the<br>// sector we want to read .<br>//移动文件指针到需要读取位置<br>SetFilePointer (hDevice,<br>(LogicalSector*512),<br>NULL,<br>FILE_BEGIN);<br><br>// reading sector(s) ...<br>//读数据<br>if (!ReadFile ( hDevice,<br>buffer,<br>512*numsec,<br>&amp;bytesread,<br>NULL) )<br>{<br>/*<br>int err;<br>char error[10];<br>err=GetLastError ();<br>itoa (err, error, 10);<br>MessageBox (error, "Reading sectors ...Failed ");<br>return NULL ;<br>*/<br>}<br>//关闭<br>CloseHandle(hDevice);<br><br>return buffer ;<br>}<br><br><br>
 
分收不回来。还是给你们了
 

Similar threads

后退
顶部