Jump to content

Recommended Posts

Posted

Hello everybody, can someone help me to resolve my problem ?

I use Drag & Drop on certain scripts, and on Windows XP or Vista without UAC, the following script work fine.

But if the UAC is activated on Vista, the GUIlist never show the dragged files. :)

#include <GuiConstants.au3>
#include <Array.au3>
#RequireAdmin

Global $WM_DROPFILES = 0x233
Global $gaDropFiles[1], $ListFile[1], $str = ""


#Region ################### GUI section ###################
$GUI_FusiOnV2 = GUICreate("GUI", 400, 335, -1, -1, -1, BitOR($WS_EX_ACCEPTFILES, $WS_EX_APPWINDOW))
$hlist = GUICtrlCreateList("", 8, 20, 385, 300)
GUICtrlSetState(-1, $GUI_DROPACCEPTED + $WS_HSCROLL)

GUISetState()
; For the Drag and Drop.
GUIRegisterMsg($WM_DROPFILES, "WM_DROPFILES_FUNC")

#EndRegion ################### GUI section ###################
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
            
        Case $GUI_EVENT_DROPPED
            ReDim $ListFile[UBound($ListFile) + UBound($gaDropFiles) ]
            For $i = 0 To UBound($gaDropFiles) - 1
                _ArrayInsert($ListFile, $i, $gaDropFiles[$i])
            Next
            
            UpdateList()
            
    EndSwitch
WEnd
Exit

#Region ################### Fonctions ###################
; Fonction pour la gestion du Drag And Drop.
Func WM_DROPFILES_FUNC($hWnd, $msgID, $wParam, $lParam)
    Local $nSize, $pFileName
    Local $nAmt = DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $wParam, "int", 0xFFFFFFFF, "ptr", 0, "int", 255)
    For $i = 0 To $nAmt[0] - 1
        $nSize = DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $wParam, "int", $i, "ptr", 0, "int", 0)
        $nSize = $nSize[0] + 1
        $pFileName = DllStructCreate("char[" & $nSize & "]")
        DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $wParam, "int", $i, "ptr", DllStructGetPtr($pFileName), "int", $nSize)
        ReDim $gaDropFiles[$i + 1]
        $gaDropFiles[$i] = DllStructGetData($pFileName, 1)
        $pFileName = 0
    Next
EndFunc  ;==>WM_DROPFILES_FUNC

; Fonction de mise à jour de l'affichage des fichiers.
Func UpdateList()
    $str = "|"
    For $i = 0 To UBound($ListFile) - 1
        If $ListFile[$i] <> "" Then $str &= $ListFile[$i] & "|"
    Next
    GUICtrlSetData($hlist, $str)
EndFunc  ;==>UpdateList
#EndRegion ################### Fonctions ###################

Best Regards.Thierry

Posted

I don't know why, but if I don't use #RequireAdmin, the code work under Vista with UAC actived !!!

Can someone give an explication of that ?

Best Regards.Thierry

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
×
×
  • Create New...