CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: How to get ShortCut working dir

  1. #1
    Join Date
    Feb 2002

    How to get ShortCut working dir

    How do I get the working directory
    of a windows (.ink) shortcut file, from within my Visual Basic 6 program!

    I have tested numerous times to extract the path from the Binary
    (1k .Ink) file

    There has to be some API routine that do this??

    I have tested the ( VB 5 IShellLinkA Interface(ANSI) )
    But it will not return working directory for all shortcuts!

    and also it's a VB5 type library

  2. #2
    Join Date
    May 2000
    New York, NY, USA

    Re: How to get ShortCut working dir

    'Set a reference to Microsoft Shell Controls and Automation

    private Sub Command1_Click()
    Dim s as Shell
    Dim fi as FolderItem
    Dim f as Folder
    Dim l as ShellLinkObject
    Dim i as Long

    set s = new Shell
    set f = s.BrowseForFolder(me.hWnd, "Select Folder", 0, ssfDESKTOP)
    for i = 0 to f.Items.Count - 1
    set fi = f.Items.Item(i)
    If fi.IsLink then
    set l = fi.GetLink
    MsgBox fi.Name & vbCrLf & _
    l.Description & vbCrLf & _
    l.Path & vbCrLf & _
    l.WorkingDirectory & vbCrLf & _
    End If
    set l = nothing
    set fi = nothing
    set f = nothing
    set s = nothing
    End Sub

    Iouri Boutchkine
    Iouri Boutchkine

  3. #3
    Join Date
    Feb 2002

    Re: How to get ShortCut working dir

    Thanx for the reply! That really works!

    I also found another way to do it by using this
    "VB 5 IShellLinkA "

    What is best to use "IShellLinkA " or your way
    I guess your way is better since "IShellLinkA " works on old VB5 library!

  4. #4
    Join Date
    Mar 2002

    Re: How to get ShortCut working dir

    Your code works fine, but how do you get the stored path from a known .lnk file? Your solution requires that the user choose a folder, and reveals all paths of all .lnks in that folder.
    I have a known .lnk in a known folder and I simply want to read that .lnk's stored path. How do you get the path without using BrowseForFolder?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)