实现格式化磁盘

fangchao918628 2009-10-12 10:52:02
不是使用SHFormatDrive,这个会有界面弹出来!
...全文
611 23 打赏 收藏 转发到动态 举报
写回复
用AI写文章
23 条回复
切换为时间正序
请发表友善的回复…
发表回复
myshinji 2009-10-15
  • 打赏
  • 举报
回复
晕了,

This device I/O control operation is for floppy disk devices only

白顶了.....

不晓得,fmifs.dll可不可以在vista下使用……
myshinji 2009-10-15
  • 打赏
  • 举报
回复
看了15楼的内容,觉得果然没白mark此贴。。
dnfreeuser 2009-10-14
  • 打赏
  • 举报
回复
分区表取容量
自己设置有关信息
fangchao918628 2009-10-14
  • 打赏
  • 举报
回复
[Quote=引用 18 楼 dnfreeuser 的回复:]
底层磁盘写
直接用空白磁盘的信息覆盖到新磁盘上去

以上仅是一个想法...
[/Quote]
想过,但是每个磁盘容量不一样,信息有差别
dnfreeuser 2009-10-14
  • 打赏
  • 举报
回复
底层磁盘写
直接用空白磁盘的信息覆盖到新磁盘上去

以上仅是一个想法...
boolpc 2009-10-14
  • 打赏
  • 举报
回复
这个兔子天天能看到。。。
pady_pady 2009-10-14
  • 打赏
  • 举报
回复
mark
MoXiaoRab 2009-10-14
  • 打赏
  • 举报
回复
帮你找了好久,找到了。累。


IOCTL_DISK_FORMAT_TRACKS(已经被后面那个取代)和IOCTL_DISK_FORMAT_TRACKS_EX


BOOL DeviceIoControl(
(HANDLE) hDevice, // handle to device
IOCTL_DISK_FORMAT_TRACKS, // dwIoControlCode
(LPVOID) lpInBuffer, // input buffer
(DWORD) nInBufferSize, // size of input buffer
(LPVOID) lpOutBuffer, // output buffer
(DWORD) nOutBufferSize, // size of output buffer
(LPDWORD) lpBytesReturned, // number of bytes returned
(LPOVERLAPPED) lpOverlapped // OVERLAPPED structure
);


hDevice
A handle to the floppy disk to be formatted. To retrieve a device handle, call the CreateFile function.

dwIoControlCode
The control code for the operation. Use IOCTL_DISK_FORMAT_TRACKS for this operation.

lpInBuffer
A pointer to a buffer that contains a FORMAT_PARAMETERS data structure.

nInBufferSize
The size of the input buffer, in bytes.

lpOutBuffer
A pointer to a buffer that receives a variable number of elements of the BAD_TRACK_NUMBER type. Each element contains the track number of one bad disk track.

nOutBufferSize
The size of the output buffer, in bytes.

lpBytesReturned
A pointer to a variable that receives the size of the data stored in the output buffer, in bytes.

If the output buffer is too small to receive any data, the call fails, GetLastError returns ERROR_INSUFFICIENT_BUFFER, and lpBytesReturned is zero.

If the output buffer is too small to hold all of the data but can hold some entries, some drivers will return as much data as fits. In this case, the call fails, GetLastError returns ERROR_MORE_DATA, and lpBytesReturned indicates the amount of data received. Your application should call DeviceIoControl again with the same operation, specifying a new starting point.

If lpOverlapped is NULL, lpBytesReturned cannot be NULL. Even when an operation returns no output data and lpOutBuffer is NULL, DeviceIoControl makes use of lpBytesReturned. After such an operation, the value of lpBytesReturned is meaningless.

If lpOverlapped is not NULL, lpBytesReturned can be NULL. If this parameter is not NULL and the operation returns data, lpBytesReturned is meaningless until the overlapped operation has completed. To retrieve the number of bytes returned, call GetOverlappedResult. If hDevice is associated with an I/O completion port, you can retrieve the number of bytes returned by calling GetQueuedCompletionStatus.

lpOverlapped
A pointer to an OVERLAPPED structure.

If hDevice was opened without specifying FILE_FLAG_OVERLAPPED, lpOverlapped is ignored.

If hDevice was opened with the FILE_FLAG_OVERLAPPED flag, the operation is performed as an overlapped (asynchronous) operation. In this case, lpOverlapped must point to a valid OVERLAPPED structure that contains a handle to an event object. Otherwise, the function fails in unpredictable ways.

For overlapped operations, DeviceIoControl returns immediately, and the event object is signaled when the operation has been completed. Otherwise, the function does not return until the operation has been completed or an error occurs.

参考http://msdn.microsoft.com/en-us/library/aa365161(VS.85).aspx
MoXiaoRab 2009-10-14
  • 打赏
  • 举报
回复
我觉得,系统的格式化应该是和磁盘驱动进行交互的结果

也不知道是哪个IOCTRL码,没研究过
fangchao918628 2009-10-14
  • 打赏
  • 举报
回复
上面我弄错了,我用的是3楼的方法!!没的成功
klkvc386 2009-10-13
  • 打赏
  • 举报
回复
Mark
ldolphiny 2009-10-13
  • 打赏
  • 举报
回复
学习 学习
cnzdgs 2009-10-13
  • 打赏
  • 举报
回复
3楼正解
fangchao918628 2009-10-13
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 delphiwcdj 的回复:]
http://www.codeproject.com/KB/dialog/cformatdrivedialog.aspx
[/Quote]
这上面的我试了好像磁盘是虚拟出来的不行啊!
myshinji 2009-10-12
  • 打赏
  • 举报
回复
这个文章号啊,收藏!!!!
fangchao918628 2009-10-12
  • 打赏
  • 举报
回复
TO:tttyd
我做低格过后要能使用还得进行高格!这时候应该怎么处理?
StarsunYzL 2009-10-12
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 delphiwcdj 的回复:]
C/C++ code
DWORD SHFormatDrive(
HWND hwnd,
UINT drive,//0 for A:, 2 for C:,... UINT fmtID,//SHFMT_ID_DEFAULT only ¡­
[/Quote]

人家LZ都说了不用SHFormatDrive,认真看帖嘛~~
delphiwcdj 2009-10-12
  • 打赏
  • 举报
回复
  
DWORD SHFormatDrive(
HWND hwnd,
UINT drive,//0 for A:, 2 for C:,...
UINT fmtID,//SHFMT_ID_DEFAULT only
UINT options//SHFMT_OPT_FULL取消快格,进行全格
//SHFMT_OPT_SYSONLY 创建ms-dos启动盘
);
StarsunYzL 2009-10-12
  • 打赏
  • 举报
回复
试试FormatEx,需要动态LoadLibrary、GetProcAddress获取函数地址:

GetProcAddress(LoadLibrary(_T("fmifs.dll")), "FormatEx");

详细请看:

http://blog.csdn.net/bluesun777/archive/2008/03/14/2181492.aspx
加载更多回复(2)

2,643

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 硬件/系统
社区管理员
  • 硬件/系统社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧