用Delphi怎样读写硬盘绝对扇区?(100分)

  • 主题发起人 主题发起人 111222
  • 开始时间 开始时间
1

111222

Unregistered / Unconfirmed
GUEST, unregistred user!
我现在正急用这一功能。可以加分
 
好像以前谁回答过。其实是汇编的事情,与Delphi没有多大关系,在NT下还无效。
 
http://www.21jx.com/~haoxg/<br>看一下 《迷你编辑器》
 
说得更清楚一些:要读出硬盘在指定的[面、磁道、起始扇区、扇区数]的数据,<br>相当于C语言中的biosdisk(cmd,drive,head,track,sector,nsects,*buf)。<br>例如,能读写硬盘分区表就能拿分(仅限于Delphi语言)。<br>应该用int 13h
 
我曾经用C++ BUILDER 编写如下的程序来读区物理磁盘的绝对扇区,对软盘可用,但对硬盘不管用<br>不知问题出在哪里,请各位指教:<br>void __fastcall TForm1::Button1Click(TObject *Sender)<br>{<br>&nbsp; &nbsp; &nbsp; &nbsp; DWORD w;<br>&nbsp; &nbsp; &nbsp; &nbsp; int v;<br>&nbsp; &nbsp; &nbsp; &nbsp; hDevice=CreateFile("////.//VWIN32",GENERIC_WRITE|GENERIC_READ,FILE_SHARE_READ|FILE_SHARE_WRITE,<br>&nbsp; &nbsp; &nbsp; &nbsp; NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);<br>&nbsp; &nbsp; &nbsp; &nbsp; if(hDevice!=NULL)<br>&nbsp; &nbsp; &nbsp; &nbsp; { &nbsp;w=1;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;w=w&lt;&lt;8;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;v=0x80;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;reg.reg_EAX=0x440D;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;reg.reg_EBX=v|w;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;reg.reg_ECX=0x084B;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;reg.reg_EDX=1;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;reg.reg_Flags=0x0001;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fresult=DeviceIoControl(hDevice,VWIN32_DIOC_DOS_IOCTL,&amp;reg,sizeof(reg),&amp;reg,sizeof(reg),&amp;cb1,0);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if(!fresult||(reg.reg_Flags &amp; 0x0001))<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ShowMessage("Fail1");<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;reg.reg_EAX=0x0201; //读硬盘的0面0柱面1扇区,数量为一扇区.<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;reg.reg_EBX=(DWORD)&amp;boot; //定义为 BYTE boot[512];<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;reg.reg_ECX=0x0001;//<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;reg.reg_EDX=v;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;reg.reg_Flags=0x0001;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;fresult=DeviceIoControl(hDevice,VWIN32_DIOC_DOS_INT13,&amp;reg,sizeof(reg),&amp;reg,sizeof(reg),&amp;cb1,0);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if(!fresult||(reg.reg_Flags &amp; 0x0001))<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ShowMessage("Fail2");<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Edit2-&gt;Text=AnsiString(boot[StrToInt(Edit1-&gt;Text)]);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;reg.reg_EAX=0x440d;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;reg.reg_EBX=v;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;reg.reg_ECX=0x086b;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;reg.reg_Flags=0x0001;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;DeviceIoControl(hDevice,VWIN32_DIOC_DOS_IOCTL,&amp;reg,sizeof(reg),&amp;reg,sizeof(reg),&amp;cb1,0);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if(!fresult||(reg.reg_Flags &amp; 0x0001))<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ShowMessage("Fail3");<br>&nbsp; &nbsp; &nbsp; &nbsp; }<br><br>}
 
9X下很简单,NT下要调用系统的东西,有代码公布过的,在大富翁找找吧。
 
有人直接提供答案吗?<br>我只用过汇编,<br>还不知道在Win9x/nt下如何实现!
 
跟进》》
 
接受答案了.
 
后退
顶部