如何使用文件复制对话框
下面图老师小编跟大家分享一个简单易学的如何使用文件复制对话框教程,get新技能是需要行动的,喜欢的朋友赶紧收藏起来学习下吧!
文件复制对话框,无法从进度条上判断当前复制的进度.那么,如何做到这一点呢?请看下面:
PublicTypeSHFILEOPSTRUCT
hWndAsLong
wFuncAsLong
pFromAsString
pToAsString
fFlagsAsInteger
fAnyOperationsAbortedAsBoolean
hNameMappingsAsLong
lpszProgressTitleAsString
EndType
PublicDeclareFunctionSHFileOperationLib"shell32.dll"Alias
_
"SHFileOperationA"(lpFileOpAsSHFILEOPSTRUCT)AsLong
PublicConstFO_COPY=&H2
PublicConstFOF_ALLOWUNDO=&H40
PublicSubShellCopyFile(SourceAsString,DestAsString)
DimresultAsLong
DimfileopAsSHFILEOPSTRUCT
Withfileop
.hwnd=0
.wFunc=FO_COPY
'ThefilestocopyseparatedbyNullsandterminatedby2nulls
.pFrom=Source&vbNullChar&vbNullChar
'ortocopyallfilesusethisline
'.pFrom="C:*.*"&vbNullChar&vbNullChar
'Thedirectoryorfilename(s)tocopyintoterminatedin2nulls
.pTo=Dest&vbNullChar&vbNullChar
.fFlags=FOF_ALLOWUNDO
EndWith
result=SHFileOperation(fileop)
Ifresult<>0Then'Operationfailed
'MsgboxtheerrorthatoccurredintheAPI.
MsgBoxErr.LastDllError,vbCriticalOrvbOKOnly
Else
Iffileop.fAnyOperationsAborted<>0Then
MsgBox"OperationFailed",vbCriticalOrvbOKOnly
EndIf
EndIf
EndSub
只需调用ShellCopyFileFileA,FileACopy->