|
-
Nov 2nd, 2000, 05:51 AM
#1
Thread Starter
Hyperactive Member
Hi Guys
I made a post yesterday about a piece of code I was having trouble
understanding. It used an api function SHFileOperation
Heres the code
Public Function MakeBackUp(ByVal bvDatabase As Database, ByVal bvBackupDatabase As String) As Boolean
Dim strMsg As String
Dim tshFileOp As SHFILEOPSTRUCT
Dim lngRet As Long
Dim strSaveFile As String
Dim lngFlags As Long
Const cERR_USER_CANCEL = vbObjectError + 1
Const cERR_DB_EXCLUSIVE = vbObjectError + 2
On Local Error GoTo MakeBackup_Err
If DBExclusive(bvDatabase) = True Then
Err.Raise cERR_DB_EXCLUSIVE
End If
lngFlags = FOF_SIMPLEPROGRESS Or _
FOF_FILESONLY Or _
FOF_RENAMEONCOLLISION
******************************************************
strSaveFile = CurrentDBDir & bvBackupDatabase & ".mdb"
With tshFileOp
.wFunc = FO_COPY
.hwnd = hWndAccessApp
.pFrom = bvDatabase.Name & vbNullChar
.pTo = strSaveFile & vbNullChar
.fFlags = lngFlags
End With
lngRet = SHFileOperation(tshFileOp)
MakeBackUp = (lngRet = 0)
*******************************************************
MakeBackup_End:
The bit between the * is the part I think should come out, or rather I
was advised by Jop. He said to put this in :
Public Function MakeBackUp(ByVal bvDatabase As Database, ByVal bvBackupDatabase As String) As Boolean
******
If DBExclusive(bvDatabase) = True Then Err.Raise
strSaveFile = CurrentDBDir & bvBackupDatabase & ".mdb"
FileCopy bvDatabase.Name & vbNullChar, strSaveFile & vbNullChar
*****
'This just copies the file... that's all what the other code does right?
End Function
I have no idea what my code is trying to do ( I have taken this app over from someone who has
left the company) could someone talk me through what the api is trying to do.
what does the tshfileop bit do !
If it as simple as what Jop said why would anyone complicate it in this
way ? ( BTW I dont doubt your suggestion for one minute Jop ) I just need an explanation of
what is happening, I am nervous about removing bits of code that are
already there and screwing up the prog as it is buisness critical.
If I put Jops suggested solution in do I still need the lines
lngRet = SHFileOperation(tshFileOp)
MakeBackUp = (lngRet = 0)
I have also found this type declared in the dec part of this module which is related to the code above
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
Thanks for your previous help and any given today
Locutus
[Edited by locutus on 11-02-2000 at 05:59 AM]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|