Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Invoke Windows Explorer copying progress bar/ or flash messages 1

Status
Not open for further replies.

mb22

Programmer
Joined
Sep 4, 2002
Messages
258
Location
US
While running the SHELL to copy a large file using DOS xcopy, .... how can I flash a message to the user ..say
"File copy in progress..."

or also how can I invoke the Windows Explorer copying window with the its progrees bar when copying?
 
Use SHFileOperation API for copying files.
___
Private Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long
Private Type SHFILEOPSTRUCT
hwnd As Long
wFunc As Long
pFrom As String
pTo As String
fFlags As Integer
fAnyOperationsAborted As Long
hNameMappings As Long
lpszProgressTitle As String
End Type
Private Const FO_COPY = &H2

Private Sub CopyFile(ByVal src As String, ByVal dst As String)
Dim fos As SHFILEOPSTRUCT
fos.hwnd = hwnd
fos.pFrom = src
fos.pTo = dst
fos.wFunc = FO_COPY
SHFileOperation fos
End Sub

Private Sub Form_Load()
CopyFile "C:\Data\db1.mdb", "D:\Backup\db2.mdb"
End Sub

 
thank you very much.
 
hypetia, kindly explain your code. i think this is the one i need. thanx

kilroy [trooper]
 
I think the code is very simple. When you copy the file using CopyFile procedure, it calls the SHFileOperation API for performing this task. Before calling this function it initializes the related structure SHFILEOPSTRUCT.
.hwnd member is the owner window which has to own the copy progress window.
.pFrom and .pTo specify the source and destination filename and,
.wFunc specifies the function to be performed, FO_COPY in this case.

SHFileOperation uses the internal copy method used by Windows and also shows the copy progress which is the main requirement in our case.

For more information,
See SHFileOperation function.

and SHFILEOPSTRUCT structure.
 
will this copy only the NEWER files into the target directory?

kilroy [trooper]
 
No it will try to copy all files to the target directory. If an older file already exist, it will ask you to overwrite as Windows does.

However, you may bypass this overwrite confirmation by specifying the NOCONFIRMATION flag in the .fFlags member of SHFILEOPSTRUCT structure.
This supresses any confirmations and overwrites existing older files, if there are any.

The NOCONFIRMATION flag is declared as:
Code:
Const FOF_NOCONFIRMATION = &H10
 
this means i can't use this to copy newer files (sadly). any alternative to achieve this goal? thanx :)


kilroy [trooper]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top