?
Solved

*.lnk file format

Posted on 1998-03-12
10
Medium Priority
?
553 Views
Last Modified: 2010-04-06
Can someone please tell me what the file format of win95`s
Shortcut files (*.lnk) is. The people from windows95 general
have been giving me pages & pages of info on things working in C etc. not in delphi. I'm writing a instal program to instal another system on PCs and need to create a shortcut on the program startup menu.
0
Comment
Question by:Deep Diver
[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
  • 5
  • 4
10 Comments
 
LVL 3

Expert Comment

by:williams2
ID: 1360430
You need to deal with Windows API methods to do this properly, I can see what I can find till tommorow...
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1360431
If you want to know the file format : www.wotsit.demon.co.uk/wwindows/lnk.zip
Regards, Zif.
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1360432
Here already the way to read a Shell Link :


{
 Can't use Standard OpenDialog since it really
 opens .lnk file and returns the command string,
 associated with link.
}
unit SLI_Unit;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ExtCtrls, StdCtrls, OLE2, ShlObj, ComCtrls, Menus;

type
  TForm1 = class(TForm)
    Edit0: TEdit;
    Button1: TButton;
    Panel1: TPanel;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Edit2: TEdit;
    Edit3: TEdit;
    Edit4: TEdit;
    Label7: TLabel;
    Edit1: TEdit;
    HotKey1: THotKey;
    procedure Button1Click(Sender: TObject);
    procedure ShowLinkInfo;
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
begin
   ShowLinkInfo;
end;
procedure TForm1.ShowLinkInfo;
Var
 Desc : Array[0..MAX_PATH] of Char;
 SL   : IShellLink;
 PF   : IPersistFile;
 HRES : HRESULT;
 FD   : TWin32FindData;
begin
 CoInitialize(Nil);
 HRes := COCreateInstance(CLSID_ShellLink, Nil, CLSCTX_INPROC_SERVER,
                          IID_IShellLink, SL);
 If Succeeded(HRes) Then
  Begin
   HRes := SL.QueryInterface(IID_IPersistFile, PF);
   If Succeeded(HRes) Then
    Begin
     Edit0.Text := 'D:\LINKDEMO.LNK';
     PF.Load('D:\LINKDEMO.LNK', STGM_READ);
     SL.Resolve(Handle, SLR_ANY_MATCH);
     SL.GetPath(Desc, MAX_PATH, FD, SLGP_UNCPRIORITY);
     Edit1.Text := StrPas(Desc);
     SL.GetDescription(Desc, MAX_PATH);
     Edit2.Text := StrPas(Desc);
     SL.GetWorkingDirectory(Desc, MAX_PATH);
     Edit3.Text := StrPas(Desc);
     SL.GetArguments(Desc, MAX_PATH);
     Edit4.Text := StrPas(Desc);
     PF.Release;
     SL.Release;
    End;
  End;
end;
end.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 8

Accepted Solution

by:
ZifNab earned 600 total points
ID: 1360433
And this is the way to create a Shell Link


// Shows how to create Shell Link
unit SL_Unit;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  OLE2, ShlObj, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Edit1: TEdit;
    procedure Button1Click(Sender: TObject);
    procedure Abort(Text : String);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
var
 sPath  : Array[0..MAX_PATH] of Char;
 Path   : String;
 HRes   : HRESULT;    
 SL     : IShellLink;     //ShellLink
 PF     : IPersistFile;   //  PersistentFile
begin
 GetWindowsDirectory(sPath, MAX_PATH);
 Path := StrPas(sPath);
 Path := Path + '\DESKTOP\';
 Edit1.Text := Path;

 CoInitialize(Nil);
 HRes := COCreateInstance(CLSID_ShellLink, Nil, CLSCTX_INPROC_SERVER,
                          IID_IShellLink, SL);
 If Succeeded(HRes) Then
  Begin
   HRes := SL.QueryInterface(IID_IPersistFile, PF);
   If Succeeded(HRes) Then
    Begin
     HRes := SL.SetPath('d:\windows\notepad.exe');
     If Not(Succeeded(HRes)) Then Abort('Error ShellLink.SetPath');
     HRes := SL.SetArguments('c:\autoexec.bat');
     If Not(Succeeded(HRes)) Then Abort('Error ShellLink.SetArguments');
     HRes := SL.SetDescription('Shell Link Demo');
     If Not(Succeeded(HRes)) Then Abort ('Error ShellLink.SetDesc');
     HRes := PF.Save('d:\windows\desktop\linkdemo.lnk', True);
     If Not(Succeeded(HRes)) Then Abort('Error PersistFile.Save');
     PF.Release;
     SL.Release;
    End Else Abort('Error PersistFile');
  End Else Abort('Error ShellLink');
end;

procedure TForm1.Abort;
begin
 MessageDlg(Text, mtError, [mbOk], 0);
 Close;
end;

end.

Regards Zif.

And this makes the circle round.....

Hope you've got enough information, now. C.U.

0
 

Author Comment

by:Deep Diver
ID: 1360434
Many TNX ZifNab!
I'll just be testing.
0
 

Author Comment

by:Deep Diver
ID: 1360435
We (I) have got a bit of a problem here...
I dont seem to have two files needed for this "program".
  Windows.DCU
  SHLObj.DCU

Do you know where I can find it?
0
 

Author Comment

by:Deep Diver
ID: 1360436
Oh yeh I see now I forgot to say that this needs to work in delphi 1.

regards
riaan
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1360437
In D1 Windows is splitted in two parts, namely WinTypes and WinProcs.
About ShlObj i'm not sure. But you can find a version on this page :

http://www.connect.net/jordanr/

in his freeware setup program he uses this one and the program works also for D1.

So have a look.

Regards, Zif.
0
 

Author Comment

by:Deep Diver
ID: 1360438
ShlObj.dcu is wrong format according to D1

However, I'm going to award your points.
Many TNX for a good strait forward answer!

0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1360439
Thanks Deep Driver... If you still need help, I'm here...
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

764 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