Solved

Type structure for LNK files

Posted on 1998-07-27
3
374 Views
Last Modified: 2008-02-26
Hi all

Does anyone know the type structure for WIN95/98 Shell Link (LNK) files? I would like to have the ability to read the executable name contained within the LNK, so I can obtain it's icon.
TIA.

Regards,
Tony
0
Comment
Question by:scvb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 9

Accepted Solution

by:
cymbolic earned 100 total points
ID: 1466798
Its avariable format, so a type structure will not work, but you will notice a consistency in a hex dump of .lnk files that allows you to find and pick out the path/file name.  See below:
000000  4C 00 00 00 01 14 02 00-00 00 00 00 C0 00 00 00  L   ¶     +
000010  00 00 00 46 1B 00 00 00-20 00 00 00 20 5E 9C 03     F        ^£
000020  63 8D BD 01 00 48 FA 49-9A 92 BD 01 00 5C E9 98  cì+ H·IÜÆ+ \_ÿ
000030  9D 4F BA 01 70 04 01 00-00 00 00 00 01 00 00 00  ¥O¦p     
000040  00 00 00 00 00 00 00 00-00 00 00 00 60 00 14 00              ` ¶
000050  1F 00 E0 4F D0 20 EA 3A-69 10 A2 D8 08 00 2B 30   _O- _:ió+ +0
000060  30 9D 19 00 23 43 3A 5C-00 00 00 00 00 00 00 00  0¥ #C:\
000070  00 00 00 00 00 00 00 00-00 11 EE 17 00 31 00 00           _ 1
000080  00 00 00 3D 21 F7 9E 10-80 57 69 6E 64 6F 77 73     =!_PÇWindows
000090  00 00 1A 00 32 00 70 04-01 00 EB 1E 40 76 20 80     2 p _@v Ç
0000A0  54 65 6C 6E 65 74 2E 65-78 65 00 00 00 00 44 00  Telnet.exe    D
0000B0  00 00 1C 00 00 00 01 00-00 00 1C 00 00 00 2D 00             -
0000C0  00 00 00 00 23 43 43 00-00 00 11 00 00 00 03 00      #CC      
0000D0  00 00 EB 15 29 1C 10 00-00 00 00 43 3A 5C 57 49    _§)    C:\WI
0000E0  4E 44 4F 57 53 5C 54 45-4C 4E 45 54 2E 45 58 45  NDOWS\TELNET.EXE
0000F0  00 00 0C 00 2E 5C 54 45-4C 4E 45 54 2E 45 58 45      .\TELNET.EXE
000100  0A 00 43 3A 5C 57 49 4E-44 4F 57 53              
 C:\WINDOWS

and another:

000000  4C 00 00 00 01 14 02 00-00 00 00 00 C0 00 00 00  L   ¶     +
000010  00 00 00 46 0B 00 00 00-20 00 00 00 00 48 58 2F     F         HX/
000020  44 D4 BB 01 00 08 BD CA-3E 90 BD 01 00 48 58 2F  D++ +->É+ HX/
000030  44 D4 BB 01 10 65 00 00-00 00 00 00 01 00 00 00  D++e      
000040  00 00 00 00 00 00 00 00-00 00 00 00 86 00 14 00              å ¶
000050  1F 00 E0 4F D0 20 EA 3A-69 10 A2 D8 08 00 2B 30   _O- _:ió+ +0
000060  30 9D 19 00 23 43 3A 5C-00 00 00 00 00 00 00 00  0¥ #C:\
000070  00 00 00 00 00 00 00 00-00 11 EE 20 00 31 00 00           _  1
000080  00 00 00 38 22 7D A5 10-00 4D 53 4F 66 66 69 63     8"}Ñ MSOffic
000090  65 00 4D 53 4F 46 46 49-43 45 00 1C 00 31 00 00  e MSOFFICE  1
0000A0  00 00 00 38 22 7D A5 10-00 4F 66 66 69 63 65 00     8"}Ñ Office
0000B0  4F 46 46 49 43 45 00 1B-00 32 00 10 65 00 00 71  OFFICE  2 e  q
0000C0  21 00 28 20 80 4F 75 74-6C 6F 6F 6B 2E 65 78 65  ! ( ÇOutlook.exe
0000D0  00 00 00 00 4D 00 00 00-1C 00 00 00 01 00 00 00      M      
0000E0  1C 00 00 00 2D 00 00 00-46 49 43 45 4C 00 00 00     -   FICEL
0000F0  11 00 00 00 03 00 00 00-EB 15 29 1C 10 00 00 00        _§)
000100  00 43 3A 5C 4D 53 4F 66-66 69 63 65 5C 4F 66 66   C:\MSOffice\Off
000110  69 63 65 5C 4F 55 54 4C-4F 4F 4B 2E 45 58 45 00  ice\OUTLOOK.EXE
000120  00 21 00 2E 2E 5C 2E 2E-5C 4D 53 4F 66 66 69 63   ! ..\..\MSOffic
000130  65 5C 4F 66 66 69 63 65-5C 4F 55 54 4C 4F 4F 4B  e\Office\OUTLOOK
000140  2E 45 58 45                                      .EXE


Which indicate that you can read them in as binary files (very short files), look for x'1C 10 00 00 00 00' followed by your path/file name.  A good tool to examint hem is Verne Buerg's List program, which has a hex viewing format.  The above 2 hex dumps are not 100% because of conversion by the IE browser software.
0
 
LVL 6

Expert Comment

by:alamo
ID: 1466799
In general, depending upon interpreting a binary file with an undocumented format which is subject to change is a bad idea. There's a defined automation interface with which you can get the filename, IShellLnk.
0
 
LVL 39

Expert Comment

by:abel
ID: 1466800
In addition to alamo's comment, there's a very easy to use .TLB on your VB-cdrom in the TOOLS\UNSUPPRT\SHELLLNK directory. It comes with an example and you can easily get whatever you want from an icon.

Regards, Abel
0

Featured Post

Want Experts Exchange at your fingertips?

With Experts Exchange’s latest app release, you can now experience our most recent features, updates, and the same community interface while on-the-go. Download our latest app release at the Android or Apple stores today!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month5 days, 3 hours left to enroll

635 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question