readWindowsShortcut.Rd
Reads a Microsoft Windows Shortcut (.lnk file).
# S3 method for default
readWindowsShortcut(con, verbose=FALSE, ...)
A connection
or a character
string (filename).
If TRUE
, extra information is written while reading.
Not used.
Returns a list
structure.
The MIME type for a Windows Shortcut file is
application/x-ms-shortcut
.
createWindowsShortcut
() and
filePath()
[1] Wotsit's Format, http://www.wotsit.org/, 2005.
[2] Hager J, The Windows Shortcut File Format
(as reverse-engineered by), version 1.0.
[3] Microsoft Developer Network, IShellLink Interface, 2018.
https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/nn-shobjidl_core-ishelllinka
[4] Andrews D, Parsing Windows Shortcuts (lnk) files in java,
comp.lang.java.help, Aug 1999.
https://groups.google.com/d/topic/comp.lang.java.help/ouFHsH1UgKI
[5] Multiple authors, Windows shell links (in Tcl), Tcler's Wiki,
April 2008. https://wiki.tcl-lang.org/1844
[6] Daniel S. Bensen, Shortcut File Format (.lnk), Stdlib.com,
April 24, 2009.
https://web.archive.org/web/20110817051855/http://www.stdlib.com/art6-Shortcut-File-Format-lnk.html (was http://www.stdlib.com/art6-Shortcut-File-Format-lnk.html)
[7] [MS-SHLLINK]: Shell Link (.LNK) Binary File Format, Microsoft Inc.,
September 25, 2009.
pathname <- system.file("data-ex/HISTORY.LNK", package="R.utils")
lnk <- readWindowsShortcut(pathname)
# Print all information
print(lnk)
#> $header
#> $header$magic
#> [1] 76
#>
#> $header$guid
#> [1] 1 20 2 0 0 0 0 0 192 0 0 0 0 0 0 70
#>
#> $header$flags
#> hasShellItemIdList pointsToFileOrDirectory hasDescription
#> TRUE TRUE TRUE
#> hasRelativePath hasWorkingDirectory hasCommandLineArguments
#> TRUE TRUE FALSE
#> hasCustomIcon unicodedStrings
#> FALSE TRUE
#>
#> $header$fileAttributes
#> isReadOnly isHidden isSystemFile
#> FALSE FALSE FALSE
#> isVolumeLabel isDirectory isModifiedSinceLastBackup
#> FALSE FALSE TRUE
#> isEncrypted isNormal isTemporary
#> FALSE FALSE FALSE
#> isSparseFile hasReparsePointData isCompressed
#> FALSE FALSE FALSE
#> isOffline
#> FALSE
#>
#> $header$creationTime
#> [1] 755506800
#>
#> $header$modificationTime
#> [1] -1773539680
#>
#> $header$lastAccessTime
#> [1] 755113120
#>
#> $header$fileLength
#> [1] 606
#>
#> $header$iconNumber
#> [1] 0
#>
#> $header$showWndValue
#> SW_NORMAL
#> 1
#>
#> $header$hotKey
#> [1] 0
#>
#> $header$unknown
#> [1] 0 0
#>
#>
#> $fileLocationInfo
#> $fileLocationInfo$flags
#> availableOnLocalVolume availableOnNetworkShare
#> TRUE FALSE
#>
#> $fileLocationInfo$localVolumeTable
#> $fileLocationInfo$localVolumeTable$typeOfVolume
#> Fixed
#> 3
#>
#> $fileLocationInfo$localVolumeTable$volumeSerialNumber
#> [1] -2077904061
#>
#> $fileLocationInfo$localVolumeTable$volumeLabel
#> [1] "IBM_PRELOAD"
#>
#>
#> $fileLocationInfo$basePathname
#> [1] "C:\\Documents and Settings\\hb\\braju.com.R\\R.utils\\R.utils\\inst\\HISTORY"
#>
#> $fileLocationInfo$remainingPathname
#> [1] ""
#>
#>
#> $description
#> [1] "C:\\Documents and Settings\\hb\\braju.com.R\\R.utils\\R.utils\\inst\\HISTORY"
#>
#> $relativePath
#> [1] "..\\HISTORY"
#>
#> $workingDirectory
#> [1] "C:\\Documents and Settings\\hb\\braju.com.R\\R.utils\\R.utils\\inst"
#>
#> $relativePathname
#> [1] "..\\HISTORY"
#>
#> $pathname
#> [1] "C:\\Documents and Settings\\hb\\braju.com.R\\R.utils\\R.utils\\inst\\HISTORY"
#>
# Get the relative path to the target file
history <- file.path(dirname(pathname), lnk$relativePath)
# Alternatively, everything in one call
history <- filePath(pathname, expandLinks="relative")