Opened 3 weeks ago
Last modified 13 days ago
#4073 new Bug
Missing $FOFX_ constants
| Reported by: | Nine | Owned by: | |
|---|---|---|---|
| Milestone: | Component: | AutoIt | |
| Version: | 3.3.18.0 | Severity: | None |
| Keywords: | Cc: |
Description
All $FOF_ constants are defined in APIShellExConstants.au3. But all $FOFX_ constants are missing. For consistency reason, they should be added.
Attachments (0)
Change History (9)
comment:1 by , 2 weeks ago
comment:2 by , 2 weeks ago
I am using them with interface COM created by ObjCreateInterface for IFileOperation (replacement of _WinAPI_ShellFileOperation since Vista). I suppose it can be compared to this other Track
comment:3 by , 2 weeks ago
I have no horse in the race, but to save legwork if need be ;)
Pulled from ShObjIdl_core.h (or here)
Global Const $FOFX_NOSKIPJUNCTIONS = 0x00010000 ; Don't avoid binding to junctions (like Task folder, Recycle-Bin) Global Const $FOFX_PREFERHARDLINK = 0x00020000 ; Create hard link if possible Global Const $FOFX_SHOWELEVATIONPROMPT = 0x00040000 ; Show elevation prompts when error UI is disabled (use with FOF_NOERRORUI) Global Const $FOFX_RECYCLEONDELETE = 0x00080000 ; Recycle when deleting, rather than permanently deleting Global Const $FOFX_EARLYFAILURE = 0x00100000 ; Fail operation as soon as a single error occurs rather than trying to process other items (applies only when using FOF_NOERRORUI) Global Const $FOFX_PRESERVEFILEEXTENSIONS = 0x00200000 ; Rename collisions preserve file extns (use with FOF_RENAMEONCOLLISION) Global Const $FOFX_KEEPNEWERFILE = 0x00400000 ; Keep newer file on naming conflicts Global Const $FOFX_NOCOPYHOOKS = 0x00800000 ; Don't use copy hooks Global Const $FOFX_NOMINIMIZEBOX = 0x01000000 ; Don't allow minimizing the progress dialog Global Const $FOFX_MOVEACLSACROSSVOLUMES = 0x02000000 ; Copy security information when performing a cross-volume move operation Global Const $FOFX_DONTDISPLAYSOURCEPATH = 0x04000000 ; Don't display the path of source file in progress dialog Global Const $FOFX_DONTDISPLAYDESTPATH = 0x08000000 ; Don't display the path of destination file in progress dialog Global Const $FOFX_REQUIREELEVATION = 0x10000000 ; User expects the elevation; don't show a dialog to confirm Global Const $FOFX_ADDUNDORECORD = 0x20000000 ; This is a user-invoked operation, and should be placed on the undo stack. This flag is preferred to FOF_ALLOWUNDO Global Const $FOFX_COPYASDOWNLOAD = 0x40000000 ; Show Downloading instead of Copying Global Const $FOFX_DONTDISPLAYLOCATIONS = 0x80000000 ; Hides the locations line in the progress dialog
comment:4 by , 2 weeks ago
A bit more info if its helpful.
The existing FOF_* consts look to be defined to service _WinAPI_ShellFileOperation. They are used in a SHFILEOPSTRUCT struct, but I don't think the FOFX_ values are legal there. (just going by the info in the link).
comment:6 by , 2 weeks ago
Nine might know different, but I don't think those FOFX_ constants are used outside of the IFileOperation interface.
So until someone writes a standard UDF for that, perhaps it'd be better to hold off?
comment:7 by , 2 weeks ago
Yes it is only being useful in IFileOperation (not working with ShellFileOperation). But I'm not a big fan of having part of the constants list in one file, and have to put the other part locally. It might just be me, however I don't any harm having the full list in the official #include.
comment:9 by , 13 days ago
Here a few methods :
; From Nine
#include <WinAPI.au3>
#include <File.au3>
#include <WinAPIDiag.au3>
Opt("MustDeclareVars", True)
Global Const $FOFX_ADDUNDORECORD = 0x20000000
Global Const $FOFX_RECYCLEONDELETE = 0x00080000
Global Const $FOFX_NOCOPYHOOKS = 0x00800000
Global Const $IID_IShellItem = "{43826D1E-E718-42EE-BC55-A1E261C37BFE}"
Global Const $tIIDIShellItem = _WinAPI_GUIDFromString($IID_IShellItem)
Global Const $CLSID_IFileOperation = "{3AD05575-8857-4850-9277-11B85BDB8E09}"
Global Const $IID_IFileOperation = "{947AAB5F-0A5C-4C13-B4D6-4BF7836FC9F8}"
Global Const $tagIFileOperation = _
"Advise hresult(ptr;dword*);" & _
"Unadvise hresult(dword);" & _
"SetOperationFlags hresult(dword);" & _
"SetProgressMessage hresult(wstr);" & _
"SetProgressDialog hresult(ptr);" & _
"SetProperties hresult(ptr);" & _
"SetOwnerWindow hresult(hwnd);" & _
"ApplyPropertiesToItem hresult(ptr);" & _
"ApplyPropertiesToItems hresult(ptr);" & _
"RenameItem hresult(ptr;wstr;ptr);" & _
"RenameItems hresult(ptr;wstr);" & _
"MoveItem hresult(ptr;ptr;wstr;ptr);" & _
"MoveItems hresult(ptr;ptr);" & _
"CopyItem hresult(ptr;ptr;wstr;ptr);" & _
"CopyItems hresult(ptr;ptr);" & _
"DeleteItem hresult(ptr;ptr);" & _
"DeleteItems hresult(ptr);" & _
"NewItem hresult(ptr;dword;wstr;wstr;ptr);" & _
"PerformOperations hresult();" & _
"GetAnyOperationsAborted hresult(ptr*);"
Global Const $IID_IShellFolder = "{000214E6-0000-0000-C000-000000000046}"
Global Const $tagIShellFolder = _
"ParseDisplayName hresult(hwnd;ptr;wstr;dword*;ptr*;dword*);" & _ ; These methods accepts PIDLs that are relative to the parent folder
"EnumObjects hresult(hwnd;dword;ptr*);" & _
"BindToObject hresult(ptr;ptr;struct*;ptr*);" & _
"BindToStorage hresult(ptr;ptr;ptr;ptr*);" & _
"CompareIDs hresult(lparam;ptr;ptr);" & _
"CreateViewObject hresult(hwnd;ptr;ptr*);" & _
"GetAttributesOf hresult(uint;struct*;ulong*);" & _
"GetUIObjectOf hresult(hwnd;uint;struct*;struct*;uint*;ptr*);" & _
"GetDisplayNameOf hresult(ptr;uint;struct*);" & _
"SetNameOf hresult(hwnd;ptr;wstr;dword;ptr*);"
;CreateNewItem(@ScriptDir & "\New", "Test.txt")
;CreateNewItem(@ScriptDir & "\New", "Test", True)
Func CreateNewItem($sPath, $sFile, $bFolder = False)
Local $iAttrib = $bFolder ? $FILE_ATTRIBUTE_DIRECTORY : 0
If Not FileExists($sPath) Then DirCreate($sPath)
Local $oIFileOperation = ObjCreateInterface($CLSID_IFileOperation, $IID_IFileOperation, $tagIFileOperation)
Local $pIShellItem = SHCreateItemFromParsingName($sPath, 0, DllStructGetPtr($tIIDIShellItem))
$oIFileOperation.NewItem($pIShellItem, $iAttrib, $sFile, "", 0)
$oIFileOperation.PerformOperations()
EndFunc ;==>CreateNewItem
;CopyItem(@ScriptFullPath, @ScriptDir & "\New")
Func CopyItem($sPathFrom, $sPathTo, $iFlags = BitOR($FOFX_ADDUNDORECORD, $FOFX_RECYCLEONDELETE, $FOFX_NOCOPYHOOKS, $FOF_NOCONFIRMATION))
If Not FileExists($sPathFrom) Then Return SetError(1)
If Not FileExists($sPathTo) Then DirCreate($sPathTo)
Local $oIFileOperation = ObjCreateInterface($CLSID_IFileOperation, $IID_IFileOperation, $tagIFileOperation)
Local $pIShellItemFrom = SHCreateItemFromParsingName($sPathFrom, 0, DllStructGetPtr($tIIDIShellItem))
Local $pIShellItemTo = SHCreateItemFromParsingName($sPathTo, 0, DllStructGetPtr($tIIDIShellItem))
$oIFileOperation.SetOperationFlags($iFlags)
$oIFileOperation.CopyItem($pIShellItemFrom, $pIShellItemTo, "", 0)
$oIFileOperation.PerformOperations()
EndFunc ;==>CopyItem
Func SHCreateItemFromParsingName($sPath, $pPbc, $pRIID)
Local $aRes = DllCall("shell32.dll", "long", "SHCreateItemFromParsingName", "wstr", $sPath, "ptr", $pPbc, "ptr", $pRIID, "ptr*", 0)
If @error Or $aRes[0] Then Return SetError(1)
Return $aRes[4]
EndFunc ;==>SHCreateItemFromParsingName
;DeleteItem(@ScriptDir & "\New\Test.txt")
Func DeleteItem($sFile)
If FileExists($sFile) Then
_WinAPI_ShellFileOperation($sFile, '', $FO_DELETE, BitOR($FOF_ALLOWUNDO, $FOF_NO_UI))
EndIf
EndFunc ;==>DeleteItem
CreateNewItem(@ScriptDir & "\New", "Test1.txt")
CreateNewItem(@ScriptDir & "\New", "Test2.txt")
Local $aFile = _FileListToArray(@ScriptDir & "\New", "*.txt", $FLTA_FILES, False)
_ArrayDisplay($aFile)
RenameItems(@ScriptDir & "\New", $aFile, "TestNew.txt")
Func RenameItems($sPath, $aFileOld, $sFileNew)
Local $oIFileOperation = ObjCreateInterface($CLSID_IFileOperation, $IID_IFileOperation, $tagIFileOperation)
Local $pPIDL = _WinAPI_ShellILCreateFromPath($sPath)
Local $tPtr = DllStructCreate("ptr array[" & $aFile[0] & "]")
For $i = 1 To $aFile[0]
$tPtr.array(($i)) = _WinAPI_ShellILCreateFromPath($sPath & '\' & $aFileOld[$i])
Next
Local $aRet = DllCall("shell32.dll", "long", "SHCreateShellItemArray", "ptr", $pPIDL, "ptr", 0, "uint", $aFile[0], "struct*", $tPtr, "ptr*", 0)
$oIFileOperation.SetOperationFlags($FOF_RENAMEONCOLLISION)
$oIFileOperation.RenameItems($aRet[5], $sFileNew)
$oIFileOperation.PerformOperations()
EndFunc ;==>RenameItems
;RenameItem(@ScriptDir & "\New\Test1.txt", "TestNew.txt")
Func RenameItem($sFileOld, $sFileNew)
Local $oIFileOperation = ObjCreateInterface($CLSID_IFileOperation, $IID_IFileOperation, $tagIFileOperation)
Local $pIShellItem = SHCreateItemFromParsingName($sFileOld, 0, DllStructGetPtr($tIIDIShellItem))
ConsoleWrite($pIShellItem & @CRLF)
$oIFileOperation.RenameItems($pIShellItem, $sFileNew)
$oIFileOperation.PerformOperations()
EndFunc ;==>RenameItem

Hi
in which function those constants are they used ?