说三道四技术文摘-感悟人生的经典句子
说三道四 > 文档快照

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

HTML文档下载 WORD文档下载 PDF文档下载
VB使用浏览器的文件复制对话框

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_FunctionsFO_MOVE = &H1FO_COPY = &H2FO_DELETE = &H3FO_RENAME = &H4End EnumPublic Enum FOF_FlagsFOF_MULTIDESTFILES = &H1FOF_CONFIRMMOUSE = &H2FOF_SILENT = &H4FOF_RENAMEONCOLLISION = &H8FOF_NOCONFIRMATION = &H10FOF_WANTMAPPINGHANDLE = &H20FOF_ALLOWUNDO = &H40FOF_FILESONLY = &H80FOF_SIMPLEPROGRESS = &H100FOF_NOCONFIRMMKDIR = &H200FOF_NOERRORUI = &H400FOF_NOCOPYSECURITYATTRIBS = &H800FOF_NORECURSION = &H1000FOF_NO_CONNECTED_ELEMENTS = &H2000FOF_WANTNUKEWARNING = &H4000End EnumPublic Type SHNAMEMAPPINGpszOldPath As StringpszNewPath As StringcchOldPath As LongcchNewPath As LongEnd Type
备案号:鲁ICP备13029499号-2 说三道四 www.s3d4.cn 说三道四技术文摘