Programming library  » Articles Articles
Shortcut File Format (.lnk)

» Shortcut File Format (.lnk)

Page: 1 of 3
By: Daniel
Last updated: 24 April

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 

1. Header
SizeContentsDescription
4 bytes Always 4C 00 00 00 This is how windows knows it is a shortcut file
16 bytes GUID for shortcut files The 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 dword Shortcut flags Shortcut flags are explained below
1 dword Target file flags Flags are explained below
1 qword Creation time  
1 qword Last access time  
1 qword Modification time  
1 dword File length The 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 dword Icon number If 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 dword Show Window the ShowWnd value to pass to the target application when starting it. 1:Normal Window 2:Minimized 3:Maximized
1 dword Hot Key The hot key assigned for this shortcut
1 dword Reserved Always 0
1 dword Reserved Always 0

Shortcut flags
BitMeaning
0 Shell item id list is present
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
BitMeaning
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)
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.

Last Access and Modified time offsets corrected thanks to JimmyW
Pages: 1 2 3
| Next 
Programming help
Do you have problems
with your code?
Please send your question to: askphp@stdlib.com
Somebody will try to help you.

Articles
ProgrammingProgramming
    » Two Programmers
    » Make and Makefiles

AlgorithmsAlgorithms
    » Roulette Wheel

DataData
    » Shortcut File Format (.lnk)

WebWeb
    » Installing PHP on your PC

MediaMedia

Stdlib WebsiteStdlib Website
    » How to add an article
    » Stdlib.com Rules


Small?
Small but growing!


Do you know where to get programming help? ... Stdlib.com !