Applecore Pages on Microsoft Access

Getting the target that is executed by a shortcut

If you want to find the target that is executed by a shortcut, either on the desktop, or from the Program files menu, then the easiest way is to use the Windows Scripting Host library to do this:

Public Function fGetShortcutTarget(strShortcut As String) As String
'   Accepts:
'       strShortcut - the path and name of the shortcut that we want to get the information for
'   Returns:
'       The target of the given shortcut
'   Notes: Uses the Windows Scripting Host

    On Error GoTo E_Handle
    Dim objShell As Object, objLink As Object
    Set objShell = CreateObject("WScript.Shell")
    Set objLink = objShell.CreateShortcut(strShortcut)
    fGetShortcutTarget = objLink.TargetPath
fExit:
    On Error Resume Next
    Set objLink = Nothing
    Set objShell = Nothing
    Exit Function
E_Handle:
    MsgBox Err.Description & vbCrLf & "fGetShortcutTarget", vbOKOnly + vbCritical, "Error: " & Err.Number
    Resume fExit
End Function

Top

 


HOME | NEW | TABLES | QUERIES | FORMS | REPORTS | GENERAL | API | DOWNLOADS | TUTORIAL | RESOURCES
E-MAIL
Copyright & Disclaimer

 

Last modified at 06/06/2006 14:57:19