VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



This code gives access to File Explorer capabilities and shows progress dialog and / or error dialo

by T-REX Software (14 Submissions)
Category: Files/File Controls/Input/Output
Compatability: Visual Basic 4.0 (32-bit)
Difficulty: Unknown Difficulty
Originally Published: Wed 24th March 1999
Date Added: Mon 8th February 2021
Rating: (1 Votes)

This code gives access to File Explorer capabilities and shows progress dialog and / or error dialogs

API Declarations



Public Const FO_MOVE As Long = &H1
Public Const FO_COPY As Long = &H2
Public Const FO_DELETE As Long = &H3
Public Const FO_RENAME As Long = &H4
Public Const FOF_MULTIDESTFILES As Long = &H1
Public Const FOF_CONFIRMMOUSE As Long = &H2
Public Const FOF_SILENT As Long = &H4
Public Const FOF_RENAMEONCOLLISION As Long = &H8
Public Const FOF_NOCONFIRMATION As Long = &H10
Public Const FOF_WANTMAPPINGHANDLE As Long = &H20
Public Const FOF_CREATEPROGRESSDLG As Long =&H0
Public Const FOF_ALLOWUNDO As Long = &H40
Public Const FOF_FILESONLY As Long = &H80
Public Const FOF_SIMPLEPROGRESS As Long = &H100
Public Const FOF_NOCONFIRMMKDIR As Long = &H200

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

Declare Function SHFileOperation Lib "Shell32.dll" Alias "SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long



Rate This code gives access to File Explorer capabilities and shows progress dialog and / or error dialo




Dim result As Long, fileop As SHFILEOPSTRUCT
With fileop
        .hwnd = Me.hwnd
        .wFunc = FO_COPY
        .pFrom = "C:\PROGRAM FILES\MICROSOFT VISUAL BASIC\VB.HLP" & vbNullChar & "C:\PROGRAM FILES\MICROSOFT VISUAL BASIC\README.HLP" & vbNullChar & vbNullChar
'       .pFrom = "C:\*.*" & vbNullChar & vbNullChar
        .pTo = "C:\testfolder" & vbNullChar & vbNullChar
        .fFlags = FOF_SIMPLEPROGRESS Or FOF_FILESONLY
End With
result = SHFileOperation(fileop)
If result <> 0 Then
        ' Operation failed
        MsgBox Err.LastDllError 
Else
        If fileop.fAnyOperationsAborted <> 0 Then
                      MsgBox "Operation Failed"
         End If
End If

Download this snippet    Add to My Saved Code

This code gives access to File Explorer capabilities and shows progress dialog and / or error dialo Comments

No comments have been posted about This code gives access to File Explorer capabilities and shows progress dialog and / or error dialo. Why not be the first to post a comment about This code gives access to File Explorer capabilities and shows progress dialog and / or error dialo.

Post your comment

Subject:
Message:
0/1000 characters