private declare function shformatdrive lib "shell32.dll"(byval hwnd as long,byval drive as long,fmtid as long,options as long) as long private const shfmt_id_default=&hffff&dim lret as long lret=shformatdrive(me.hwnd,0,shfmt_id_default,0) select case lret case -2 msgbox "ok" case msgbox "cannot format a read only drive" end select end sub 请慎重使用
Public Declare Function SHFileOperation Lib "shell32.dll" Alias " SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As LongPublic Type SHFILEOPSTRUCT hwnd As Long wFunc As Long pFrom As String pTo As String fFlags As Integer fAnyOperationsAborted As Long hNameMappings As Long lpszProgressTitle As String ' only used if FOF_SIMPLEPROGRESS End Typedim filleoperation as shfileopstruct dim lreturn as long dim stemp as string stemp="c:\temp.txt" with fileoperation .wfunc=FD_DELETE .pfrom=stemp .fflags=FOF_ALLOWUNDO end with lreturn=shfileoperation(fileoperation)
private const shfmt_id_default=&hffff&dim lret as long
lret=shformatdrive(me.hwnd,0,shfmt_id_default,0)
select case lret
case -2
msgbox "ok"
case
msgbox "cannot format a read only drive"
end select
end sub
请慎重使用
hwnd As Long
wFunc As Long
pFrom As String
pTo As String
fFlags As Integer
fAnyOperationsAborted As Long
hNameMappings As Long
lpszProgressTitle As String ' only used if FOF_SIMPLEPROGRESS
End Typedim filleoperation as shfileopstruct
dim lreturn as long
dim stemp as string
stemp="c:\temp.txt"
with fileoperation
.wfunc=FD_DELETE
.pfrom=stemp
.fflags=FOF_ALLOWUNDO
end with
lreturn=shfileoperation(fileoperation)