G'day
@TheArkive,
I needed to use SHFileOperationW in a project, which is how I came upon your solution, but because I also needed the renamed mappings, I found it cleaner to code my own solution afresh.
In doing that, I noticed you have another minor issue in your SHFileOperation structure at...
Code: Select all
Static hwnd := 0
, wFunc := (A_PtrSize=4) ? 4 : 8
, From := (A_PtrSize=4) ? 8 : 16
, To := (A_PtrSize=4) ? 12 : 24
, Flags := (A_PtrSize=4) ? 16 : 32
, AnyOpsAbort := (A_PtrSize=4) ? 20 : 36
, NameMappings := (A_PtrSize=4) ? 24 : 40
, ProgressTitle := (A_PtrSize=4) ? 28 : 48
In the x64 structure, a 32 bit Int is used for fFlags just as you've coded for, but in the x86 structure, it's a 16 bit Short. You're assuming the former for both cases.
For x64, you're fine, but for x86 you're currently 16 bits overstated. Consequently, you don't fetch the correct values from the structure for fAnyOperationAborted, hNameMappings or lpszProgressTitle
You're not currently dealing with the renamed mappings in your solution, so that's moot, but you do fetcch an incorrect result for fAnyOperationAborted under x86.
You can test it under x86 and x64 to see the issues with...
Code: Select all
obj := FileOps()
obj.FlagStr := 'NORECURSION RENAMEONCOLLISION WANTMAPPINGHANDLE'
obj.copy('u:\source\*', 'u:\target')
MsgBox(obj.Abort)
For an excellent solution "someone" developed for testing under different AHK versions, can I point you to...
viewtopic.php?f=6&t=73056
For myself, I've coded the SHFileOpStructW, hNameMappings and SHNameMappingW structures as...
Code: Select all
; SHFileOpStructW
Static Mhwnd := Map('Offset', 0, 'Type', 'Ptr'), ; HWND 8 4
MwFunc := Map('Offset', (x64 ? 8 : 4), 'Type', 'Ptr'), ; UINT 8 4
MpFrom := Map('Offset', (x64 ? 16 : 8), 'Type', 'Ptr'), ; PCZZSTR 8 4
MpTo := Map('Offset', (x64 ? 24 : 12), 'Type', 'Ptr'), ; PCZZSTR 8 4
MfFlags := Map('Offset', (x64 ? 32 : 16), 'Type', (x64 ? 'Int' : 'Short')), ; FILEOP_FLAGS 4 2
MfAnyOperationAborted := Map('Offset', (x64 ? 36 : 18), 'Type', 'Int'), ; BOOL 4 4
MhNameMappings := Map('Offset', (x64 ? 40 : 22), 'Type', 'Ptr'), ; LPVOID 8 4
MlpszProgressTitle := Map('Offset', (x64 ? 48 : 26), 'Type', 'Ptr'), ; PCSTR 8 4
MTotalSHFileOpStructW := (x64 ? 56 : 30)
; hNameMappings
Static MMappingsCount := Map('Offset', 0, 'Type', 'Ptr'), ; UINT 8 4
MSHNameMappingW := Map('Offset', (x64 ? 8 : 4), 'Type', 'Ptr'), ; ptr 8 4
MTotalhNameMappings := (x64 ? 16 : 8)
; SHNameMappingW
Static MpszOldPath := Map('Offset', 0, 'Type', 'Ptr'), ; LPSTR 8 4
MpszNewPath := Map('Offset', (x64 ? 8 : 4), 'Type', 'Ptr'), ; LPSTR 8 4
McchOldPath := Map('Offset', (x64 ? 16 : 8), 'Type', 'Int'), ; int 4 4
McchNewPath := Map('Offset', (x64 ? 20 : 12), 'Type', 'Int'), ; int 4 4
MTotalSHNameMappingW := (x64 ? 24 : 16)
I hope that's of use to you.
Best regards,
LBJ