您的位置:首页 > 其它

【转】快捷方式lnk文件格式详解(英文)

2011-07-12 15:18 393 查看
转自:http://www.stdlib.com/art6-Shortcut-File-Format-lnk.html

You should consider using the
IShellLink
interface which is a safe way to handle windows shortcuts. If you have a strong reason not to use that interface then I have to remind you that this file format is not documented by Microsoft. I cannot say that the info gathered here is accurate nor that it will work in the future.

.LNK File Format
1. Header
2. Shell Item Id List
3. File Location Info
4. Description
5. Relative Path
6. Working Directory
7. Command Line Arguments
8. Icon Filename
9. Additonal Info
[align=center]1. Header[/align]
SizeContentsDescription
4 bytesAlways 4C 00 00 00This is how windows knows it is a shortcut file
16 bytesGUID for shortcut filesThe current GUID for shortcuts. It may change in the future. 01 14 02 00 00 00 00 00 C0 00 00 00 00 00 46
1 dwordShortcut flagsShortcut flags are explained below
1 dwordTarget file flagsFlags are explained below
1 qwordCreation time
1 qwordLast access time
1 qwordModification time
1 dwordFile lengthThe length of the target file. 0 if the target is not a file. This value is used to find the target when the link is broken.
1 dwordIcon numberIf the file has a custom icon (set by the flags bit 6), then this long integer indicates the index of the icon to use. Otherwise it is zero.
1 dwordShow Windowthe ShowWnd value to pass to the target application when starting it. 1:Normal Window 2:Minimized 3:Maximized
1 dwordHot KeyThe hot key assigned for this shortcut
1 dwordReservedAlways 0
1 dwordReservedAlways 0
[align=center]Shortcut flags[/align]
BitMeaning
0Shell item id list is present
1Target is a file or directory
2Has a description
3Has a relative path
4Has a working directory
5Has command line arguments
6Has a custom icon.
[align=center]Target flags[/align]
BitMeaning
0Target is read only.
1Target is hidden.
2Target is a system file.
3Target is a volume label. (Not possible)
4Target is a directory.
5Target has been modified since last backup. (archive)
6Target is encrypted (NTFS partitions)
7Target is Normal
8Target is temporary.
9Target is a sparse file.
10Target has reparse point data.
11Target is compressed.
12Target is offline.
Last Access and Modified time offsets corrected thanks to JimmyW

Shell Item Id List

Note: This section exists only if the first bit for shortcut flags is set the header section. If that bit is not set then this section does not exists.

The first
word
contains the size of the list in bytes. Each item (except the last) in the list contains its size in a
word
fallowed by the content. The size includes and the space used to store it. The last item has the size 0. These items are used to store various informations. For more info read the
SHITEMID
documentation.

File Location Info

This section is always present, but if bit 1 is not set in the flags value, then the length of this section will be zero. The header of this section is described below.

SizeDescription
1 dwordThis length value includes all the assorted pathnames and other data structures. All offsets are relative to the start of this section.
1 dwordThe offset at which the basic file info structure ends. Should be 1C.
1 dwordFile available on local volume (0) or network share(1)
1 dwordOffset to the local volume table.
1 dwordOffset to the base path on the local volume.
1 dwordOffset to the network volume table.
1 dwordOffset to the final part of the pathname.
Combine the base path string and the final path string to find the filename of the file on the local volume. To find the filename of the file on the network you need to combine the share name in the network volume table with the final path string.

[align=center]The local volume table[/align]
SizeDescription
1 dwordLength of this structure including the volume label string.
1 dwordType of volume (code below)
1 dwordVolume serial number
1 dwordOffset of the volume name (Always 0x10)
ASCIZVolume label
[align=center]Type of volumes[/align]
CodeDescription
0Unknown
1No root directory
2Removable (Floppy, Zip ...)
3Fixed (Hard disk)
4Remote (Network drive)
5CD-ROM
6Ram drive
[align=center]The network volume table[/align]
SizeDescription
1 dwordLength of this structure
1 dwordAlways 02
1 dwordOffset of network share name (Always 0x14)
1 dwordReserved 0
1 dwordAlways 0x20000
ASCIZNetwork share name
Description

This section is present if bit 2 is set in the flags value in the header. The first word value indicates the length of the string. Following the length value is a string of ASCII characters. It is a description of the item.

Relative path string

This section is present if bit 3 is set in the flags value in the header. The first word value indicates the length of the string. Following the length value is a string of ASCII characters. It is a relative path to the target.

Working directory

This section is present if bit 4 is set in the flags value in the header. The first word value indicates the length of the string. Following the length value is a string of ASCII characters. It is the working directory as specified in the shortcut properties.

Command line arguments

This section is present if bit 5 is set in the flags value in the header. The first word value indicates the length of the string. Following the length value is a string of ASCII characters. The command line string includes everything except the program name.

Icon filename

This section is present if bit 6 is set in the flags value in the header. The first word value indicates the length of the string. Following the length value is a string of ASCII characters. This the name of the file containing the icon.

Additonal Info Usualy consists of a dword with the value 0.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: