Sample code for 30+ languages & platforms
Pascal (Lazarus/Delphi)

Get the Target of a Windows Shortcut

See more FileAccess Examples

Demonstrates how to get the target of a Windows shortcut.

Note: This example requires Chilkat v9.5.0.77 or greater.

Chilkat Pascal (Lazarus/Delphi) Downloads

Pascal (Lazarus/Delphi)
program ChilkatDemo;

// Demonstrates using the Chilkat Pascal wrapper via the C bridge DLL.
// Builds as a console application under Lazarus (FPC) or Delphi.

{$IFDEF FPC}
  {$MODE DELPHI}
{$ENDIF}
{$APPTYPE CONSOLE}

uses
  {$IFDEF UNIX}
  cthreads,
  {$ENDIF}
  SysUtils,
  CkDllLoader,
  Chilkat.FileAccess;

// ---------------------------------------------------------------------------

procedure RunDemo;
var
  fac: TFileAccess;
  targetPath: string;

begin
  fac := TFileAccess.Create;

  targetPath := fac.SymlinkTarget('qa_data/my_shortcut');
  if (fac.LastMethodSuccess <> True) then
    begin
      WriteLn('Failed to get shortcut target.');
      Exit;
    end;
  WriteLn('target path = ' + targetPath);


  fac.Free;

end;

// ---------------------------------------------------------------------------

begin

  try
    RunDemo;
  except
    on E: Exception do
      WriteLn('Unhandled exception: ', E.ClassName, ': ', E.Message);
  end;

  WriteLn;
  {$IFDEF MSWINDOWS}
  WriteLn('Press Enter to exit...');
  ReadLn;
  {$ENDIF}
end.