VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Copy Files Using Copy Progress Dialog

by Munim.VIP (3 Submissions)
Category: Windows API Call/Explanation
Compatability: Visual Basic 3.0
Difficulty: Intermediate
Date Added: Wed 3rd February 2021
Rating: (14 Votes)

Copy a file the using SHFileOperation API call so that Windows copy progress dialog appears...

API Declarations
'// Please Vote 4 Me, If You Like This Code...
Private Type SHFILEOPSTRUCT
hWnd As Long
wFunc As Long
pFrom As String
pTo As String
fFlags As Integer
fAnyOperationsAborted As Boolean
hNameMappings As Long
lpszProgressTitle As String
End Type
Private Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long
Private Const FO_COPY = &H2
Private Const FOF_ALLOWUNDO = &H40

Rate Copy Files Using Copy Progress Dialog

Public Sub CopyFileWindowsWay(SourceFile As String, DestinationFile As String)
   Dim lngReturn As Long
   Dim typFileOperation As SHFILEOPSTRUCT
   With typFileOperation
    .hWnd = 0
    .wFunc = FO_COPY
    .pFrom = SourceFile & vbNullChar & vbNullChar 'source file
    .pTo = DestinationFile & vbNullChar & vbNullChar 'destination file
    .fFlags = FOF_ALLOWUNDO
   End With
   lngReturn = SHFileOperation(typFileOperation)
   If lngReturn <> 0 Then 'Operation failed
     MsgBox Err.LastDllError, vbCritical Or vbOKOnly
   Else 'Aborted
     If typFileOperation.fAnyOperationsAborted = True Then
        MsgBox "Operation Failed", vbCritical Or vbOKOnly
     End If
   End If
End Sub

Download this snippet    Add to My Saved Code

Copy Files Using Copy Progress Dialog Comments

No comments have been posted about Copy Files Using Copy Progress Dialog. Why not be the first to post a comment about Copy Files Using Copy Progress Dialog.

Post your comment

Subject:
Message:
0/1000 characters