请问格式化磁盘时候用什么函数啊?

jdhsd 2006-03-02 04:50:49
我想实现按一个button按钮对D盘(非系统盘)进行格式化
请问用什么函数可以实现啊?
谢谢了
...全文
59 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
夜雨悠扬 2006-03-02
  • 打赏
  • 举报
回复
Private Declare Function GetSystemDirectory Lib "kernel32" Alias _
"GetSystemDirectoryA" (ByVal lpBuffer As String, _
ByVal nSize As Long) As Long
Private Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long

Private Declare Function ShellExecute Lib "shell32.dll" Alias _
"ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation _
As String, ByVal lpFile As String, ByVal lpParameters _
As String, ByVal lpDirectory As String, ByVal nShowCmd _
As Long) As Long

Const SW_SHOW = 5

Private Sub Command1_Click()
Dim sFor As String
Dim sTemp As String

sFor = String(260, " ")
GetWindowsDirectory sFor, 260
sTemp = Left$(sFor, InStr(sFor, Chr(0)) - 1) + "\rundll32.exe" _
+ Chr(0)
ShellExecute Me.hwnd, vbNullString, sTemp, _
"Shell32.dll,SHFormatDrive" + Chr(0), "c:\" + Chr(0), _
SW_SHOW
End Sub
这是硬盘格式化的代码,如果需要取消,只能杀死进程的方法
kill....忘了,你找一下msdn吧
夜雨悠扬 2006-03-02
  • 打赏
  • 举报
回复
Private Declare Function GetSystemDirectory Lib "kernel32" Alias _
"GetSystemDirectoryA" (ByVal lpBuffer As String, _
ByVal nSize As Long) As Long
Private Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long

Private Declare Function ShellExecute Lib "shell32.dll" Alias _
"ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation _
As String, ByVal lpFile As String, ByVal lpParameters _
As String, ByVal lpDirectory As String, ByVal nShowCmd _
As Long) As Long

Const SW_SHOW = 5
Dim sFor As String
Dim sTemp As String

sFor = String(260, " ")
GetWindowsDirectory sFor, 260
sTemp = Left$(sFor, InStr(sFor, Chr(0)) - 1) + "\rundll32.exe" + Chr(0)
ShellExecute Me.hwnd, vbNullString, sTemp, "Shell32.dll,SHFormatDrive" + Chr(0), "c:\" + Chr(0), SW_SHOW

这是硬盘格式化的代码,若需要取消的话,只能用杀死进程的方法,没有特别好的办法,继续关注
夜雨悠扬 2006-03-02
  • 打赏
  • 举报
回复
赫赫,比较难
jdhsd 2006-03-02
  • 打赏
  • 举报
回复
如果我格式化过程中要取消这个格式化操作呢?
怎么实现啊?
真相重于对错 2006-03-02
  • 打赏
  • 举报
回复
Process.Start("format.exe", "d:");

16,555

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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