Shell Read

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