How to get ShortCut working dir
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
    Posts
    6

    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
    Location
    New York, NY, USA
    Posts
    2,878

    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 & _
    l.ShowCommand
    End If
    next
    set l = nothing
    set fi = nothing
    set f = nothing
    set s = nothing
    End Sub






    Iouri Boutchkine
    iouri@hotsheet.com
    Iouri Boutchkine
    iouri@hotsheet.NOSPAM.com

  3. #3
    Join Date
    Feb 2002
    Posts
    6

    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
    Location
    NYC
    Posts
    3

    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
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center