Shortcut File Format (.lnk)快捷方式的文件格式

http://www.stdlib.com/art6-2-Shortcut-File-Format-lnk.html

 

Shortcut File Format (.lnk)
By: Daniel


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.

你最好用IShellLink 这个比较安全的接口来处理windows快捷方式。如果你有足够的理由不使用那个接口,那么我要提醒你,LNK文件格式并没有在微软的文档里公布出来。我不敢说这些格式在以后是否还有效。

 .LNK File Format (.LNK文件格式)
 1. Header (文件头)
 2. Shell Item Id List (外壳对象ID列表)
 3. File Location Info (文件位置信息)
 4. Description (描述)
 5. Relative Path (相对路径)
 6. Working Directory (工作目录)
 7. Command Line Arguments (命令行参数)
 8. Icon Filename (图标文件名)
 9. Additonal Info (额外信息)

 

1. Header(文件头)
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

译文:

大小内容描述
4 字节(8位)总是4C 00 00 00让windows知道这个是快捷方式
16 字节(8位)快捷方式的GUID 目前快捷方式的GUID,以后说不定会变; 01 14 02 00 00 00 00 00 C0 00 00 00 00 00 46
1 int32快捷键标志后文解释
1 int32目标文件标志后文解释
1 int64创建时间 
1 int64最后访问时间 
1 int64修改时间 
1 int32目标文件长度目标文件长度. 如果目标不是文件,则是0. 当链接断掉时,会用这个值来查找目标。
1 int32图标索引如果快捷方式有自定义图标(目标文件标志的第6位设置为1),这个长整形数值指出要使用图标的索引。否则是0.
1 int32显示窗口启动的目标程序将用这个值来决定显示窗口的方式。1:普通窗口2:最小化3:最大化
1 int32热键快捷方式关联的热键
1 int32保留总是0
1 int32保留总是0

 

Shortcut flags(快捷方式标志)
Bit(位)Meaning(含义)
0

Shell item id list is present

包含外壳对象ID列表。

1

Target is a file or directory

目标是文件或文件夹

2

Has a description

有描述

3

Has a relative path

有相对路径

4

Has a working directory

有工作目录

5

Has command line arguments

有命令行参数

6

Has a custom icon.

有自定义图标

 

Target flags(目标文件标志)
Bit(位)Meaning(含义)
0

Target is read only.

目标只读

1

Target is hidden.

隐藏目标

2

Target is a system file.

目标是系统文件

3

Target is a volume label. (Not possible)

目标是一个卷标(不可能)

4

Target is a directory.

目标是目录

5

Target has been modified since last backup. (archive)

目标自上次备份以来修改过了(存档)

6

Target is encrypted (NTFS partitions)

目标加密了(NTFS分区)

7

Target is Normal

目标是普通对象

8

Target is temporary.

目标是临时的

9

Target is a sparse file.

目标是碎片文件

10

Target has reparse point data.

目标包含碎片数据

11

Target is compressed.

目标压缩过的

12

Target is offline.

目标脱机

 

 

Shell Item Id List (外壳对象ID列表)

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.

注意:只有快捷方式标志的第一位等于1,那么这段才会存在。如果不是1,那么此段将不存在。

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.

第一个word表示列表的字节大小。列表中的每一个项(除了最后一个)都包含了自己的大小(内容紧跟在它的后面),用一个word 的位置来记录。这个大小包括用来存储这个大小占用的字节数。最后一个项的这个大小为0.这些项是用来存储可变信息的。更多信息参见SHITEMID文档。


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.

此段总是存在,但是,如果目标文件标志的第2位等于0,此段的长度回事0.此段的头信息解释如下:

Size(大小)Description(描述)
1 dword

This length value includes all the assorted pathnames and other data structures. All offsets are relative to the start of this section.

这个长度值包含所有路径名、其他数据结构。所有偏移量都是参照此段的开始的。 

1 dword

The offset at which the basic file info structure ends. Should be 1C.

基础文件信息结构结束的偏移量。必须是1C

1 dword

File available on local volume (0) or network share(1)

文件在本地卷:0;在网络共享:1;

1 dword

Offset to the local volume table.

本地卷表的偏移量。

1 dword

Offset to the base path on the local volume.

从本地卷基础路径的偏移量

1 dword

Offset to the network volume table.

网络卷表的偏移量

1 dword

Offset 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.

组合基础路径字符串和最终路径字符串,可以在本地卷找到文件名。要找到网络上文件的文件名,你必须组合网络卷表上的共享名和最终路径字符串。

The local volume table(本地卷表)

Size(打下)Description(描述)
1 dword

Length of this structure including the volume label string.

结构体的大小,包括卷标字符串。

1 dword

Type of volume (code below)

卷类型(代码见下)

1 dword

Volume serial number

卷序列号

1 dword

Offset of the volume name (Always 0x10)

卷名称的偏移量(总是0x10)

ASCIZ

Volume label

卷标

Type of volumes(卷类型)

Code(代码)Description(描述)
0

Unknown

未知

1

No root directory

非根目录

2

Removable (Floppy, Zip ...)

可移动(软盘/ZIP盘)

3

Fixed (Hard disk)

固定的(硬盘)

4

Remote (Network drive)

远程(网络驱动器)

5CD-ROM
6

Ram drive

内存驱动器

The network volume table(网络卷表)

Size大(大小)Description(描述)
1 dword

Length of this structure

结构体长度

1 dword

Always 02

总是0x02

1 dword

Offset of network share name (Always 0x14)

网络共享名的偏移量(总是0x14)

1 dword

Reserved 0

保留0

1 dword

Always 0x20000

总是0x20000

ASCIZ

Network 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.

如果快捷方式标志的第3位等于1,此段将会出现。第一个word的值表示字符串的长度。紧跟着长度是字符串(ASCII字符)。它描述的是这个项。


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.

如果快捷方式标志的第4位等于1,此段将会出现。第一个word的值表示字符串的长度。紧跟着长度是字符串(ASCII字符)。它是目标的相对路径。


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.

如果快捷方式标志的第5位等于1,此段将会出现。第一个word的值表示字符串的长度。紧跟着长度是字符串(ASCII字符)。它是快捷方式属性里设置的工作目录。


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.

如果快捷方式标志的第6位等于1,此段将会出现。第一个word的值表示字符串的长度。紧跟着长度是字符串(ASCII字符)。它是命令行参数,不包括程序名。


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.

如果快捷方式标志的第7位等于1,此段将会出现。第一个word的值表示字符串的长度。紧跟着长度是字符串(ASCII字符)。它是包含图标文件的路径。


Additonal Info(额外信息)

 

Usualy consists of a dword with the value 0.

通常是等于0 的DWORD。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值