我曾经用C++ BUILDER 编写如下的程序来读区物理磁盘的绝对扇区,对软盘可用,但对硬盘不管用<br>不知问题出在哪里,请各位指教:<br>void __fastcall TForm1::Button1Click(TObject *Sender)<br>{<br> DWORD w;<br> int v;<br> hDevice=CreateFile("////.//VWIN32",GENERIC_WRITE|GENERIC_READ,FILE_SHARE_READ|FILE_SHARE_WRITE,<br> NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);<br> if(hDevice!=NULL)<br> { w=1;<br> w=w<<8;<br> v=0x80;<br> reg.reg_EAX=0x440D;<br> reg.reg_EBX=v|w;<br> reg.reg_ECX=0x084B;<br> reg.reg_EDX=1;<br> reg.reg_Flags=0x0001;<br> fresult=DeviceIoControl(hDevice,VWIN32_DIOC_DOS_IOCTL,&reg,sizeof(reg),&reg,sizeof(reg),&cb1,0);<br> if(!fresult||(reg.reg_Flags & 0x0001))<br> ShowMessage("Fail1");<br> reg.reg_EAX=0x0201; //读硬盘的0面0柱面1扇区,数量为一扇区.<br> reg.reg_EBX=(DWORD)&boot; //定义为 BYTE boot[512];<br> reg.reg_ECX=0x0001;//<br> reg.reg_EDX=v;<br> reg.reg_Flags=0x0001;<br> fresult=DeviceIoControl(hDevice,VWIN32_DIOC_DOS_INT13,&reg,sizeof(reg),&reg,sizeof(reg),&cb1,0);<br> if(!fresult||(reg.reg_Flags & 0x0001))<br> ShowMessage("Fail2");<br> Edit2->Text=AnsiString(boot[StrToInt(Edit1->Text)]);<br> reg.reg_EAX=0x440d;<br> reg.reg_EBX=v;<br> reg.reg_ECX=0x086b;<br> reg.reg_Flags=0x0001;<br> DeviceIoControl(hDevice,VWIN32_DIOC_DOS_IOCTL,&reg,sizeof(reg),&reg,sizeof(reg),&cb1,0);<br> if(!fresult||(reg.reg_Flags & 0x0001))<br> ShowMessage("Fail3");<br> }<br><br>}