Get shortcut Original file path

Source: Internet
Author: User
Tags filetime

This article is to refer to the following address changes and hope to be useful to everyone. This method may not require reference to IShellLink.
http://www.vckbase.com/document/viewdoc/?id=1411

Private Type FILETIME
Dwlowdatetime as Long
Dwhighdatetime as Long
End Type

Private Type Lnkhead
Dwid as Long
Dwguid (3) as Long
dwflags as Long
dwFileAttributes as Long
Dwcreationtime as Filetime
Dwmodificationtime as Filetime
Dwlastaccesstime as Filetime
Dwfilelen as Long
Dwiconnum as Long
Dwwinstyle as Long
Dwhotkey as Long
DwReserved1 as Long
DwReserved2 as Long
End Type

Private Type Filelocationinfo
dwsize as Long
Dwfirstoffset as Long
dwflags as Long
Dwoffsetofvolume as Long
Dwoffsetofbasepath as Long
Dwoffsetofnetworkvolume as Long
Dwoffsetofremainingpath as Long
End Type

Private Type Localvolumetab
dwsize as Long
Dwtypeofvolume as Long
Dwvolumeserialnumber as Long
Dwoffsetofvolumename as Long
Strvolumename as Byte
End Type

Private Type Networkvolumetab
dwsize as Long
DwUnknown1 as Long
Dwoffsetofnetsharename as Long
DwUnknown2 as Long
DwUnknown3 as Long
Strnetsharename as Byte
End Type

Private Const lnk_hasidlist = &h1
Private Const Lnk_filedir = &h2
Private Const lnk_hasdes = &h4
Private Const Lnk_haspath = &h8
Private Const Lnk_hasworkdir = &h10
Private Const lnk_hascmd = &h20

Private Const Lnk_localvolume = &h1
Private Const lnk_netshare = &h2

Public Function Getlinkpath (ByVal strshortcut As String) as String
Dim objlinked as Lnkhead
Dim Intno As Integer, inttmp as Integer
Dim Objinfo as Filelocationinfo
Dim Intseek as Integer
Dim Bytbuffer () as Byte
Intno = FreeFile
Open strshortcut for Binary as #intNo
Get #intNo, objlinked
Intseek = Len (objlinked)
If Objlinked.dwflags and Lnk_hasidlist Then
Get #intNo, inttmp
Else
Close #intNo
Exit Function
End If
Intseek = Seek (Intno)
Intseek = Intseek + inttmp
Seek #intNo, Intseek
Get #intNo, Objinfo
Seek #intNo, Objinfo.dwoffsetofbasepath + intseek
If Objinfo.dwflags and Lnk_netshare Then
Intseek = Objinfo.dwoffsetofnetworkvolume-objinfo.dwoffsetofbasepath
Else
Intseek = Objinfo.dwoffsetofremainingpath-objinfo.dwoffsetofbasepath
End If
ReDim Bytbuffer (intSeek-1)
Get #intNo, Bytbuffer
Close #intNo
Getlinkpath = StrConv (Bytbuffer, Vbunicode)
End Function

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.