IFileOperation Interface

y programas personales para otros como tu, puede que te corrijan ;)
Avatar de Usuario
Dany
Profesional del Autoit
Mensajes: 651
Registrado: 28 Mar 2012, 22:49

IFileOperation Interface

Mensaje por Dany »

Otro ejemplo :)

Código: Seleccionar todo

Global Const $FOF_ALLOWUNDO = 0x40
Global Const $FOF_CONFIRMMOUSE = 0x2
Global Const $FOF_FILESONLY = 0x80
Global Const $FOF_MULTIDESTFILES = 0x1
Global Const $FOF_NO_CONNECTED_ELEMENTS = 0x2000
Global Const $FOF_NOCONFIRMATION = 0x10
Global Const $FOF_NOCONFIRMMKDIR = 0x200
Global Const $FOF_NOCOPYSECURITYATTRIBS = 0x800
Global Const $FOF_NOERRORUI = 0x400
Global Const $FOF_NORECURSION = 0x1000
Global Const $FOF_RENAMEONCOLLISION = 0x8
Global Const $FOF_SILENT = 0x4
Global Const $FOF_SIMPLEPROGRESS = 0x100
Global Const $FOF_WANTMAPPINGHANDLE = 0x20
Global Const $FOF_WANTNUKEWARNING = 0x4000
Global Const $FOFX_SHOWELEVATIONPROMPT = 0x00040000
Global Const $FOFX_NOCOPYHOOKS = 0x00800000
Global Const $FOFX_REQUIREELEVATION = 0x10000000

Global Const  $IID_IShellItem = "{43826d1e-e718-42ee-bc55-a1e261c37bfe}"
Global Const  $CLSID_IFileOperation = "{3AD05575-8857-4850-9277-11B85BDB8E09}"
Global Const  $IID_IFileOperation = "{947AAB5F-0A5C-4C13-B4D6-4BF7836FC9F8}"

Global Const $sTagIFileOperation = "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*);"

Local $oIFileOperation = ObjCreateInterface($CLSID_IFileOperation, $IID_IFileOperation, $sTagIFileOperation)

If IsObj($oIFileOperation) Then ConsoleWrite("Interface: " & IsObj($oIFileOperation) & @CRLF)


Local $sSource = "here source"
Local $sDestination = "here destination"

Local $tIIDIShellItem = CLSIDFromString($IID_IShellItem)


Local $pIShellItemSource = 0
Local $pIShellItemDestination = 0


_SHCreateItemFromParsingName($sSource, 0, DllStructGetPtr($tIIDIShellItem), $pIShellItemSource)
_SHCreateItemFromParsingName($sDestination, 0, DllStructGetPtr($tIIDIShellItem), $pIShellItemDestination)

ConsoleWrite("Pointer 1: " & $pIShellItemSource & @CRLF)
ConsoleWrite("Pointer 2: " & $pIShellItemDestination & @CRLF)

$oIFileOperation.SetOperationFlags($FOF_ALLOWUNDO + $FOF_NOCONFIRMMKDIR)

$oIFileOperation.CopyItems($pIShellItemSource, $pIShellItemDestination)

$oIFileOperation.PerformOperations()

$oIFileOperation = 0




Func _SHCreateItemFromParsingName($szPath, $pbc, $riid, ByRef $pv)
    Local $aRes = DllCall("shell32.dll", "long", "SHCreateItemFromParsingName", "wstr", $szPath, "ptr", $pbc, "ptr", $riid, "ptr*", 0)
    If @error Then Return SetError(1, 0, 0)
    $pv = $aRes[4]
    Return $aRes[0]
EndFunc   ;==>_SHCreateItemFromParsingName

Func CLSIDFromString($sString)
    Local $tCLSID = DllStructCreate("dword;word;word;byte[8]")
    Local $aRet = DllCall("Ole32.dll", "long", "CLSIDFromString", "wstr", $sString, "ptr", DllStructGetPtr($tCLSID))
    If @error Then Return SetError(1, @error, 0)
    If $aRet[0] <> 0 Then Return SetError(2, $aRet[0], 0)
    Return $tCLSID
EndFunc   ;==>CLSIDFromString

Saludos :smt027
  • ............................................Imagen
    ......................................Imagen
Responder