ive made a program to backup all my files but the problem i have is when it runs in to a problem with copying the files. i dont know what the problem is ie file corrupt or canceled by user.

so im wantig to add some sort of way or flag for handling this.

the code below works great for me
i have used lngReturn = SHFileOperation(typFO) for returning cancel but cannot figure out how to get error message on file/folder/disk error

i hope someone out there can help me???
Code:
Private Type SHFILEOPSTRUCT
    hWnd As Long
    wFunc As Long
    pFrom As String
    pTo As String
    fFlags As Long
    fAnyOperationsAborted As Long
    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_DELETE = &H3
Dim Dro
Dim DS As String
Dim DW As String
Dim MM
Dim portable
Dim DD
Dim NewSer As String
Dim prompt As String
Dim DFolder As String
Dim Dpath As String
Dim m, d
Dim XX As String
Dim SHFileOp As SHFILEOPSTRUCT
Dim lngReturn As Long

Public Sub CopyFolder(ByVal Source As String, ByVal Dest As String)
    Const FO_COPY As Long = &H2
    Const FOF_NOCONFIRMATION As Long = &H10
    Const FOF_CREATEPROGRESSDLG As Long = &H0
    Const FOF_NOCONFIRMMKDIR As Long = &H200
    Const FILE_FLAGS = FOF_NOCONFIRMATION Or FOF_CREATEPROGRESSDLG Or FOF_NOCONFIRMMKDIR
    Dim typFO As SHFILEOPSTRUCT
   
    
    With typFO
        .wFunc = FO_COPY
        .fFlags = FILE_FLAGS
        .pFrom = Source 
        .pTo = Dest 
    End With
    lngReturn = SHFileOperation(typFO)
End Sub
Private Sub Form_Load()
CopyFolder "c:\windowsggg", "F:\New Folder" 'this will create the problem im trying to sort out
If lngReturn = "1026" Then
    MsgBox "problem with file"
    End If
If lngReturn = "1223" Then
    MsgBox "canceled"
    End If

End Sub