Monica

Copy a directory using WinAPIEx function

5 posts in this topic

Hi Guys!

I'm trying to copy a folder from location A to location B. The DirCopy embedded function works great, but if the folder is large, my little program freeze, so that the user doesn't understand what's going on. I've found many solutions in this forum, but not for me.

So... All I want to do is delegate to someone the folder copy process... To Windows, obviously! :D

The API is a good solution I found... _WinAPI_CopyFileEx works like a charm, but it is for files only! :( I tried to insert a folder (with or without final /), but fails.

Is there an API functions for me? Please... help me!

:)

Reg.

Monica

PS

Attached code from help (_WinAPI_CopyFileEx)

 

prova.au3

Share this post


Link to post
Share on other sites



¿Why no use _WinAPI_ShellFileOperation or IFileOperation?

 

Saludos

Share this post


Link to post
Share on other sites

Thanks guys! I'll try and report here the result.

:)

Reg.

Monica

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Similar Content

    • Progh0st
      By Progh0st
      This peace of code does not work. I'm trying to copy all my usb files to desktop. What is wrong with it?
      DirCopy("E:", @DesktopDir & "\Backups\MyWork", $FC_OVERWRITE) ;Tried also this, not working. DirCopy("E:\", @DesktopDir & "\Backups\MyWork\", $FC_OVERWRITE)  
    • gillesg
      By gillesg
      Hi all,
      I need to make a dircopy function that correctly handle symlink and junction without duplicating files and folder.
      Let's try to be more precise
      I have the following directory structure 
      My folder---+ | |-- Local.file (regular file) |-- local folder (regular folder) |-- Target.symlink (symlink to file Local.file) |-- target.folder.symlink (symlink to folder local.folder) |-- target.folder.junction (junction to folder D:\PAC_Launchers\test\local.folder) 22/03/2016 21:42 10 Local.file 22/03/2016 21:41 <REP> local.folder 22/03/2016 21:42 11 Target.file 22/03/2016 21:40 <REP> Target.folder 22/03/2016 15:16 <JONCTION> target.folder.junction [D:\PAC_Launchers\test\local.folder] 22/03/2016 15:15 <SYMLINKD> target.folder.symlink [local.folder] 22/03/2016 07:42 <SYMLINK> Target.symlink [Local.file] To do so, i need to be able to identify that a file or a folder is a Symlink or Junction. And in that case I need to know the target of the symlink or junction.
      Does any of you have an idea or a script to do so.
      Gilles
       
    • DatMCEyeBall
      By DatMCEyeBall
      I'm trying to make a "sheet of glass" with shadow text drawn on it, the problem is that the shadow isn't transparent at all. I have absolutely no idea what I am doing wrong -  being a noob with the WinAPI stuff.   Screen-shot:   Here's the script: ; Requires AutoIT beta 3.3.9.21 or newer #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Version=Beta #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> #include <Misc.au3> #include <WinAPIGdi.au3> If Not _WinAPI_DwmIsCompositionEnabled() Then MsgBox(BitOR(16, 4096), 'Error', 'Script requires Windows Vista or later with enabled Aero theme.') Exit EndIf Global Const $STM_SETIMAGE = 0x0172 Global Const $STM_GETIMAGE = 0x0173 Global $hDarkBK = GUICreate("Dark background", 400, 40, -1, -1, -1, BitOR($WS_EX_TOOLWINDOW, $WS_EX_WINDOWEDGE)) GUISetBkColor(0) GUISetState(@SW_SHOW) Global $hGUI = GUICreate("DWM Test", 300, 20, -1, -1, -1, BitOR($WS_EX_TOOLWINDOW, $WS_EX_WINDOWEDGE, $WS_EX_TOPMOST)) GUISetBkColor(0) _WinAPI_DwmExtendFrameIntoClientArea($hGUI) Global $Pic = GUICtrlCreatePic('', 0, 0, 300, 20) Global $hPic = GUICtrlGetHandle($Pic) Global $tRECT = _WinAPI_GetClientRect($hPic) Global $Width = DllStructGetData($tRECT, 3) - DllStructGetData($tRECT, 1) Global $Height = DllStructGetData($tRECT, 4) - DllStructGetData($tRECT, 2) Global $hDC = _WinAPI_GetDC($hPic) Global $hDestDC = _WinAPI_CreateCompatibleDC($hDC) Global $hBitmap = _WinAPI_CreateCompatibleBitmap($hDC, $Width, $Height) Global $hDestSv = _WinAPI_SelectObject($hDestDC, $hBitmap) Global $hSrcDC = _WinAPI_CreateCompatibleDC($hDC) Global $hSource = _WinAPI_CreateCompatibleBitmapEx($hDC, $Width, $Height, _WinAPI_SwitchColor(_WinAPI_GetSysColor($COLOR_3DFACE))) Global $hSrcSv = _WinAPI_SelectObject($hSrcDC, $hSource) Global $hFont = _WinAPI_CreateFont(20, 0, 0, 0, $FW_NORMAL, 0, 0, 0, $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $ANTIALIASED_QUALITY, $DEFAULT_PITCH, 'Arial') _WinAPI_SelectObject($hSrcDC, $hFont) _WinAPI_DrawShadowText($hSrcDC, "Why is the shadow not transparent?", 0xFFFFFF, 0x000000, 3, 3, $tRECT) _WinAPI_BitBlt($hDestDC, 0, 0, $Width, $Height, $hSrcDC, 0, 0, $MERGECOPY) _WinAPI_ReleaseDC($hPic, $hDC) _WinAPI_SelectObject($hDestDC, $hDestSv) _WinAPI_DeleteDC($hDestDC) _WinAPI_SelectObject($hSrcDC, $hSrcSv) _WinAPI_DeleteDC($hSrcDC) _WinAPI_DeleteObject($hSource) _WinAPI_DeleteObject($hFont) ; Set bitmap to control _SendMessage($hPic, $STM_SETIMAGE, 0, $hBitmap) Global $hObj = _SendMessage($hPic, $STM_GETIMAGE) If $hObj <> $hBitmap Then _WinAPI_DeleteObject($hBitmap) EndIf GUISetState(@SW_SHOW) Global $nMsg While 1 $nMsg = GUIGetMsg() If $nMsg = $GUI_EVENT_CLOSE Then Exit WEnd  
    • guinness
      By guinness
      An example of monitoring when windows are created, closed or re-drawn.
       
      I just noticed there is an example (similar to mine) in the AutoIt beta v3.3.9.6+, though the more examples there are the better understanding users will have.

      #include <GUIConstantsEx.au3> #include <WinAPIEx.au3> Example() Func Example() Local $hGUI = GUICreate('An(other) example by guinness - 2013', Default, Default) ; Create a GUI. GUISetState(@SW_SHOW, $hGUI) GUIRegisterMsg(_WinAPI_RegisterWindowMessage('SHELLHOOK'), 'WM_SHELLHOOK') ; Define a window message and assign to the WM_SHELLHOOK function. _WinAPI_RegisterShellHookWindow($hGUI) ; Register the shell hook message to our GUI. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd _WinAPI_DeregisterShellHookWindow($hGUI) GUIDelete($hGUI) EndFunc ;==>Example Func WM_SHELLHOOK($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg Switch $wParam Case $HSHELL_GETMINRECT ConsoleWrite('Minimised/Maximised: ' & @CRLF & _ @TAB & 'PID: ' & WinGetProcess($lParam) & @CRLF & _ ; This is the PID. @TAB & 'Filename: ' & _WinAPI_GetWindowFileName($lParam) & @CRLF & _ ; This is the filepath of the window. @TAB & 'hWnd: ' & $lParam & @CRLF) ; This will be the handle of the window closed. Case $HSHELL_REDRAW ConsoleWrite('Redrawn: ' & @CRLF & _ @TAB & 'PID: ' & WinGetProcess($lParam) & @CRLF & _ ; This is the PID. @TAB & 'Filename: ' & _WinAPI_GetWindowFileName($lParam) & @CRLF & _ ; This is the filepath of the window. @TAB & 'hWnd: ' & $lParam & @CRLF) ; This will be the handle of the window closed. Case $HSHELL_WINDOWCREATED ConsoleWrite('Created: ' & @CRLF & _ @TAB & 'PID: ' & WinGetProcess($lParam) & @CRLF & _ ; This is the PID. @TAB & 'Filename: ' & _WinAPI_GetWindowFileName($lParam) & @CRLF & _ ; This is the filepath of the window. @TAB & 'hWnd: ' & $lParam & @CRLF) ; This will be the handle of the window closed. Case $HSHELL_WINDOWDESTROYED ConsoleWrite('Destroyed: ' & @CRLF & _ @TAB & 'PID: ' & WinGetProcess($lParam) & @CRLF & _ ; This will be -1. @TAB & 'Filename: ' & _WinAPI_GetWindowFileName($lParam) & @CRLF & _ ; This will be empty. @TAB & 'hWnd: ' & $lParam & @CRLF) ; This will be the handle of the window closed. Case $HSHELL_WINDOWREPLACED ConsoleWrite('Replaced: ' & @CRLF & _ @TAB & 'PID: ' & WinGetProcess($lParam) & @CRLF & _ ; This is the PID. @TAB & 'Filename: ' & _WinAPI_GetWindowFileName($lParam) & @CRLF & _ ; This is the filepath of the window. @TAB & 'hWnd: ' & $lParam & @CRLF) ; This will be the handle of the window closed. EndSwitch EndFunc ;==>WM_SHELLHOOK