各位高手在DELPHI中处样才能格式化硬盘? (200分)

  • 主题发起人 主题发起人 pc_wjh
  • 开始时间 开始时间
P

pc_wjh

Unregistered / Unconfirmed
GUEST, unregistred user!
希望哪位高手能告诉小弟相关原代码,小弟的E_MAIL:pc_wjh@163.com
小弟感激不尽。希望越快越好,谢谢!
 
老兄,你想编格式化软件啊!
 
破坏用?我试过,两种方法:
1、把命令加到Autoexec.bat中,下次开机时格式化;
2、直接用winexec等命令(我还是选择了前者)。
 
最简单的就是Winexec("Format.com",XXX); 第二个参数不记得了,你查一下帮助吧。
 
有意思,这个问题不难,有很多方法可以实现,你是想做个黑客软件吧
 
关注,我也想知道!
能不能也给写代码我呀?[:)]
oulin001@163.net
 
Winexec(pchar('command.com Format c:",sw_hide));sw_hide 隐藏dos界面
//格式不一定对,查查help
 
调用SHFormatDrive函数,这是一个隐藏的API;
查查MSDN,里面有详细的格式化说明。
 
2000下面呢/
 
http://www.delphibbs.com/delphibbs/dispq.asp?lid=261283
 
非常谢谢各位大虾的指教,希望能告诉小弟原代码和相关注释,谢谢
 

Here are some sample functions that show how to make IOCTL codes from a Win32 application. Actually using these functions to format tracks, etc., is left as an exercise for the reader. You need to have detailed knowledge of all of the low-level details of how disks work before you can successfully use these functions. There is plenty of information available in books and downloadable from the Internet to get you started.

type
TDiocRegisters = record
EBX, EDX, ECX, EAX, EDI, ESI, Flags: DWORD;
end;

TVWin32CtlCode = (ccNone, ccVWin32IntIoctl, ccVWin32Int26,
ccVWin32Int25, ccVWin32Int13);

TBiosParamBlock = packed record
BytesPerSector: Word;
SectorsPerCluster: Byte;
ReservedSectors: Word;
NumFats: Byte;
NumRootEntries: Word;
NumSectors: Word;
MediaID: Byte;
SectorsPerFat: Word;
SectorsPerTrack: Word;
NumHeads: Word;
HiddenSectors: Word;
Dummy1: Word;
TotalSectors: LongInt;
Dummy2: array[0..5] of Byte;
end;

TDeviceParamBlock = packed record
Special: Byte;
DeviceType: Byte;
DeviceAttr: Word;
NumCylinders: Word;
MediaType: Byte;
BiosParamBlock: TBiosParamBlock;
end;

TFormatParamBlock = packed record
Reserved: Byte;
Head: Word;
Cylinder: Word;
end;

function VWin32(CtlCode: TVWin32CtlCode; var Regs: TDiocRegisters): Boolean;
var
hDevice: THandle;
Count: DWORD;
begin
hDevice := CreateFile('//./VWIN32', 0, 0, nil, 0,
FILE_FLAG_DELETE_ON_CLOSE, 0);
Result := DeviceIoControl(hDevice, Ord(CtlCode), @Regs, SizeOf(Regs), @Regs, SizeOf(Regs), Count, nil);
CloseHandle(hDevice);
end;

function GetDeviceParamBlock(Drive: Char;
var ParamBlock: TDeviceParamBlock): Word;
var
Regs: TDiocRegisters;
begin
with Regs do
begin
EAX := $440D;
EBX := Ord(UpCase(Drive)) - Ord('@');
ECX := $0860;
EDX := LongInt(@ParamBlock);
VWin32(ccVWin32IntIoctl, Regs);
if (Flags and 1) <> 0 then
Result := LoWord(EAX)
else
Result := 0;
end;
end;

function SetDeviceParamBlock(Drive: Char;
var ParamBlock: TDeviceParamBlock): Word;
var
Regs: TDiocRegisters;
begin
with Regs do
begin
EAX := $440D;
EBX := Ord(UpCase(Drive)) - Ord('@');
ECX := $0840;
EDX := LongInt(@ParamBlock);
VWin32(ccVWin32IntIoctl, Regs);
if (Flags and 1) <> 0 then
Result := LoWord(EAX)
else
Result := 0;
end;
end;

function FormatTrack(Drive: Char;
var ParamBlock: TFormatParamBlock): Word;
var
Regs: TDiocRegisters;
begin
with Regs do
begin
EAX := $440D;
EBX := Ord(UpCase(Drive)) - Ord('@');
ECX := $0842;
EDX := LongInt(@ParamBlock);
VWin32(ccVWin32IntIoctl, Regs);
if (Flags and 1) <> 0 then
Result := LoWord(EAX)
else
Result := 0;
end;
end;

 
谢谢各位的指教,小弟在此有礼了.
 

Similar threads

D
回复
0
查看
2K
DelphiTeacher的专栏
D
D
回复
0
查看
2K
DelphiTeacher的专栏
D
D
回复
0
查看
1K
DelphiTeacher的专栏
D
D
回复
0
查看
1K
DelphiTeacher的专栏
D
D
回复
0
查看
1K
DelphiTeacher的专栏
D
后退
顶部