Solved

Type structure for LNK files

Posted on 1998-07-27
3
357 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
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

791 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