12月272015
AU3复制/移动文件的进度条显示方法
1,简单化的SHELL对象来实现
;_DirCopy('d:\sf','d:\aaa')
;_DirMove("d:\abc","e:\ooq")
Func _DirCopy($SourceDir,$Destdir)
;说明:利用Shell对象来实现复制文件对话框
;作者:Sanhen
Local $Shell
Local $FOF_SIMPLEPROGRESS = 16
If Not FileExists($Destdir) Then DirCreate($Destdir)
$Shell = ObjCreate("shell.application")
$Shell.namespace($Destdir).CopyHere($SourceDir,$FOF_SIMPLEPROGRESS)
EndFunc
Func _DirMove($SourceDir,$Destdir)
;说明:利用Shell对象来实现移动文件对话框
;作者:Sanhen
Local $Shell
Local $FOF_CREATEPROGRESSDLG = 16
If Not FileExists($Destdir) Then DirCreate($Destdir)
$Shell = ObjCreate("Shell.Application")
$Shell.NameSpace($Destdir).MoveHere($SourceDir, $FOF_CREATEPROGRESSDLG)
EndFunc
2,DLL方法实现
Global Const $FO_COPY = 0x0002
Global Const $FOF_ALLOWUNDO = 0x0040
_ExplorerCopy("f:\XPBAK.gho", "D:\")
Func _ExplorerCopy($source, $dest)
Local $SHFILEOPSTRUCT, $source_struct, $dest_struct
$SHFILEOPSTRUCT = DllStructCreate("hwnd hWnd;uint wFunc;ptr pFrom;ptr pTo;int fFlags;" & _
"int fAnyOperationsAborted;ptr hNameMappings;ptr lpszProgressTitle")
$source_struct = DllStructCreate("char[" & StringLen($source) + 2 & "]")
DllStructSetData($source_struct, 1, $source)
DllStructSetData($source_struct, 1, 0, StringLen($source) + 2)
$dest_struct = DllStructCreate("char[" & StringLen($dest) + 2 & "]")
DllStructSetData($dest_struct, 1, $dest)
DllStructSetData($dest_struct, 1, 0, StringLen($dest) + 2)
DllStructSetData($SHFILEOPSTRUCT, "hWnd", 0)
DllStructSetData($SHFILEOPSTRUCT, "wFunc", $FO_COPY)
DllStructSetData($SHFILEOPSTRUCT, "pFrom", DllStructGetPtr($source_struct))
DllStructSetData($SHFILEOPSTRUCT, "pTo", DllStructGetPtr($dest_struct))
DllStructSetData($SHFILEOPSTRUCT, "fFlags", $FOF_ALLOWUNDO)
DllCall("shell32.dll", "int", "SHFileOperation", "ptr", DllStructGetPtr($SHFILEOPSTRUCT))
EndFunc ;==>_ExplorerCopy
扫描二维码,在手机上阅读
发表评论
木有头像就木JJ啦!还木有头像吗?点这里申请属于你的个性Gravatar头像吧!