home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 1_2002.ISO / Data / Zips / CODE_UPLOAD8755882000.psc / modShellFileOperation.bas < prev    next >
Encoding:
BASIC Source File  |  2000-07-07  |  1.5 KB  |  49 lines

  1. Attribute VB_Name = "modShellFileOperation"
  2. 'Shell File Operation , By Max Raskin
  3.  
  4. Private Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long
  5. 'A Type for SHFileOperation API
  6. Private Type SHFILEOPSTRUCT
  7.         hwnd As Long
  8.         wFunc As Long
  9.         pFrom As String
  10.         pTo As String
  11.         fFlags As Integer
  12.         fAnyOperationsAborted As Long
  13.         hNameMappings As Long
  14.         lpszProgressTitle As String '  only used if FOF_SIMPLEPROGRESS
  15. End Type
  16. 'Enumarated Operations and Flags for SHFileOperation API
  17. Public Enum SHOps
  18.     Copy = &H2
  19.     Delete = &H3
  20.     SMove = &H1
  21.     Rename = &H4
  22. End Enum
  23. 'Flags for Shell File Operations
  24. Public Enum SHFlags
  25.     AllowUndo = &H40
  26.     CopyOnlyFiles = &H80
  27.     MultiDestinationFiles = &H1
  28.     DontPromptOnOverwrite = &H10
  29.     DontPromptOnCreateFolders = &H200
  30.     RenameIfExists = &H8
  31.     NoProgressDialog = &H4
  32.     ProgressDialogWithNoFileNames = &H100
  33. End Enum
  34.  
  35. 'Preforme file operations just like in windows explorer -
  36. 'with progress dialog
  37. Public Function ShellFileOp(hwnd As Long, Operation As SHOps, Source As String, Destination As String, Optional Flags As SHFlags, Optional ProgressDialogTitle As String)
  38.     Dim shf As SHFILEOPSTRUCT
  39.     If Flags <> 0 Then shf.fFlags = Flags
  40.     If ProgressDialogTitle <> "" Then shf.lpszProgressTitle = ProgressDialogTitle
  41.     shf.hwnd = hwnd
  42.     shf.pFrom = Source
  43.     shf.pTo = Destination
  44.     shf.wFunc = Operation
  45.     sh = SHFileOperation(shf)
  46. End Function
  47.  
  48.  
  49.