使用浏览器的文件复制对话框

使用浏览器的文件复制对话框 - 关于VB的经验之谈 - VB爱好者乐园(VBGood) - 关于VB的经验,电子教程,代码,控件,论坛,博客,微博等.

VBGood网站全文搜索 Google

搜索VBGood全站网页(全文搜索)
首页 - 经验之谈 - 使用浏览器的文件复制对话框
发表评论(0)作者:不详, 平台:VB6.0+Win98, 阅读:9784, 日期:2000-11-16

使用浏览器的文件复制对话框

By John Percival

介绍

Ever wanted to use the dialog box that appears when you do file operations in Explorer? Well, it is not
that hard to work, and can be used to provide some very neat little features for your application.
One little warning before we go too much further: you can easily use this function to delete entire
directories without any confirmation; I recommend that you create some temporary directories that
you can play about with, rather than destroying any useful directories.

All the dialog boxes are based around one function, SHFileOperation. It is very easy to use, and
only has one parameter, a SHFILEOPSTRUCT user-defined type. Here are the declarations that
you will need:

Public Declare Function SHFileOperation Lib _"shell32.dll" Alias "SHFileOperationA" 
_(lpFileOp As Any) As LongPublic Declare Sub SHFreeNameMappings Lib _"shell32.dll" (ByVal
hNameMappings As Long)Public Declare Sub CopyMemory Lib "KERNEL32" _Alias "RtlMoveMemory
" (hpvDest As Any, hpvSource _As Any, ByVal cbCopy As Long)Public Type SHFILEOPSTRUCThwnd
As LongwFunc As FO_FunctionspFrom As StringpTo As StringfFlags As
FOF_FlagsfAnyOperationsAborted As LonghNameMappings As LonglpszProgressTitle As String
'only used if FOF_SIMPLEPROGRESSEnd TypePublic Enum FO_Functions
FO_MOVE = &H1
FO_COPY = &H2
FO_DELETE = &H3
FO_RENAME = &H4
End EnumPublic Enum FOF_Flags
FOF_MULTIDESTFILES = &H1
FOF_CONFIRMMOUSE = &H2
FOF_SILENT = &H4
FOF_RENAMEONCOLLISION = &H8
FOF_NOCONFIRMATION = &H10
FOF_WANTMAPPINGHANDLE = &H20
FOF_ALLOWUNDO = &H40
FOF_FILESONLY = &H80
FOF_SIMPLEPROGRESS = &H100
FOF_NOCONFIRMMKDIR = &H200
FOF_NOERRORUI = &H400
FOF_NOCOPYSECURITYATTRIBS = &H800
FOF_NORECURSION = &H1000
FOF_NO_CONNECTED_ELEMENTS = &H2000
FOF_WANTNUKEWARNING = &H4000
End EnumPublic Type SHNAMEMAPPINGpszOldPath As StringpszNewPath As
StringcchOldPath As LongcchNewPath As LongEnd Type