Jump to content

Get .lnk value on drag


ame1011
 Share

Recommended Posts

Hi there, I'm using this code to accept drag and drop files on my whole GUI:

#include <GUIConstants.au3>

Opt("GUIOnEventMode", 1)

$gui = GUICreate("My GUI", Default, Default, Default, Default, Default, $WS_EX_ACCEPTFILES)

GUISetState()

;~ Const $WM_DROPFILES = 0x233
GUIRegisterMsg(0x233, "On_WM_DROPFILES")

While 1
    Sleep(100)
WEnd

Func On_WM_DROPFILES($hWnd, $Msg, $wParam, $lParam)
    Local $tDrop, $aRet, $iCount
    ;string buffer for file path
    $tDrop = DllStructCreate("char[260]")
    ;get file count
    $aRet = DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $wParam, "uint", -1, "ptr", DllStructGetPtr($tDrop), "int", DllStructGetSize($tDrop))
    $iCount = $aRet[0]
    ;get file paths
    For $i = 0 To $iCount-1
        $aRet = DllCall("shell32.dll", "int", "DragQueryFile","hwnd", $wParam,"uint", $i,"ptr", DllStructGetPtr($tDrop),"int", DllStructGetSize($tDrop))
        ConsoleWrite(DllStructGetData($tDrop, 1) & @CRLF)
    Next
    ;finalize
    DllCall("shell32.dll", "int", "DragFinish", "hwnd", $wParam)
    Return
EndFunc

I was just wondering how I would retrieve the link value if a .lnk file is dropped on my gui. IE if someone dropped a shortcut on the GUI, I don't want the shortcut path (C:\shortcut.lnk), instead I'd like the destination for that shortcut.

I hope that was clear, thanks in advance for any help.

[font="Impact"] I always thought dogs laid eggs, and I learned something today. [/font]
Link to comment
Share on other sites

FileGetShortcut ( "lnk" )

The array returned from this function is a single dimension array containing the following elements:

$array[0] = Shortcut target path

$array[1] = Working directory

$array[2] = Arguments

$array[3] = Description

$array[4] = Icon filename

$array[5] = Icon index

$array[6] = The shortcut state (@SW_SHOWNORMAL, @SW_SHOWMINNOACTIVE, @SW_SHOWMAXIMIZED)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...