complete dialogue sample with Delphi
------------------------------------

unit H_PDFtestrun1; // the pas-file

interface

uses
  ComObj, ActiveX, ShlObj, Registry, Windows, ShellAPI,
  Vcl.Dialogs, Vcl.Forms, Controls, SysUtils, Vcl.StdCtrls,
  Messages, Classes, Graphics, ComCtrls;
type
  TForm1 = class(TForm)
    OpenDialog1: TOpenDialog;
    Edit1: TEdit;
    Button1: TButton;
    Button2: TButton;
    Edit2: TEdit;
    Button4: TButton;
    Label1: TLabel;
    Button3: TButton;
    Button5: TButton;
    Label2: TLabel;
    Button6: TButton;
    Edit3: TEdit;
    OpenDialog2: TOpenDialog;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button5Click(Sender: TObject);
    procedure Button6Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;
  s, s2: LongInt;
  fp: WideString;
  SEInfo: TShellExecuteInfo;
  ExitCode: DWORD;
  ExecuteFile, ParamString, StartInString: string;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
begin
     If OpenDialog2.Execute Then
        Edit3.Text := OpenDialog2.FileName;
end;

procedure TForm1.Button2Click(Sender: TObject);       // Insert unlock_ald.exe into Explorer context
begin
  Edit2.Text := '';                                   // reset the result field...

  ExecuteFile := '"' + Edit1.Text + '"';              // '"' because there can be spaces in the filename...
  FillChar(SEInfo, SizeOf(SEInfo), 0);
  SEInfo.cbSize := SizeOf(TShellExecuteInfo);
  with SEInfo do
  begin
    fMask := SEE_MASK_NOCLOSEPROCESS;
    Wnd := Application.Handle;
    lpFile := PChar(ExecuteFile);
    lpParameters := PChar('" 9"');                    //  9 (insert into...) is the parameter...
    fp := ExtractFilePath('"' + Edit1.Text + '"');    //  Set the directory/path where the pdf-file exists...
    lpDirectory := PChar(fp);
    nShow := SW_HIDE;                                 //  do not show/open the command line...
  end;
  if ShellExecuteEx(@SEInfo) then
    repeat
      Application.ProcessMessages;
      GetExitCodeProcess(SEInfo.hProcess, ExitCode);
    until (ExitCode <> STILL_ACTIVE) or Application.Terminated;
  Edit2.Text := IntToStr(ExitCode);                   //  the result. 0 or 9nnn are errors - 1 is success...
end;

procedure TForm1.Button4Click(Sender: TObject);       // Remove unlock_ald.exe from Explorer context
begin
  Edit2.Text := '';                                   // reset the result field...

  ExecuteFile := '"' + Edit1.Text + '"';              // '"' because there can be spaces in the filename...
  FillChar(SEInfo, SizeOf(SEInfo), 0);
  SEInfo.cbSize := SizeOf(TShellExecuteInfo);
  with SEInfo do
  begin
    fMask := SEE_MASK_NOCLOSEPROCESS;
    Wnd := Application.Handle;
    lpFile := PChar(ExecuteFile);
    lpParameters := PChar('" 8"');                    //  8 (remove from...) is the parameter...
    fp := ExtractFilePath('"' + Edit1.Text + '"');    //  Set the directory/path where the pdf-file exists...
    lpDirectory := PChar(fp);
    nShow := SW_HIDE;                                 //  do not show/open the command line...
  end;
  if ShellExecuteEx(@SEInfo) then
    repeat
      Application.ProcessMessages;
      GetExitCodeProcess(SEInfo.hProcess, ExitCode);
    until (ExitCode <> STILL_ACTIVE) or Application.Terminated;
  Edit2.Text := IntToStr(ExitCode);                   //  the result. 0 or 9nnn are errors - 1 is success...
end;

procedure TForm1.Button3Click(Sender: TObject);       // Overwrite the original file
begin
  Edit2.Text := '';                                   // reset the result field...

  ExecuteFile := '"' + Edit1.Text + '"';              // '"' because there can be spaces in the filename...
  FillChar(SEInfo, SizeOf(SEInfo), 0);
  SEInfo.cbSize := SizeOf(TShellExecuteInfo);
  with SEInfo do
  begin
    fMask := SEE_MASK_NOCLOSEPROCESS;
    Wnd := Application.Handle;
    lpFile := PChar(ExecuteFile);
    lpParameters := PChar('"' + Edit3.Text + '" 0');  //  pdf-file and the 0 (=overwrite) are the parameters...
    fp := ExtractFilePath('"' + Edit3.Text + '"');    //  Set the directory/path where the pdf-file exists...
    lpDirectory := PChar(fp);
    nShow := SW_HIDE;                                 //  do not show/open the command line...
  end;
  if ShellExecuteEx(@SEInfo) then
    repeat
      Application.ProcessMessages;
      GetExitCodeProcess(SEInfo.hProcess, ExitCode);
    until (ExitCode <> STILL_ACTIVE) or Application.Terminated;
  Edit2.Text := IntToStr(ExitCode);                   //  the result. 0 or 9nnn are errors - 1 is success...
end;

procedure TForm1.Button5Click(Sender: TObject);       // Keep the original file and create a new file ..._conv.pdf
begin
  Edit2.Text := '';                                   // reset the result field...

  ExecuteFile := '"' + Edit1.Text + '"';              // '"' because there can be spaces in the filename...
  FillChar(SEInfo, SizeOf(SEInfo), 0);
  SEInfo.cbSize := SizeOf(TShellExecuteInfo);
  with SEInfo do
  begin
    fMask := SEE_MASK_NOCLOSEPROCESS;
    Wnd := Application.Handle;
    lpFile := PChar(ExecuteFile);
    lpParameters := PChar('"' + Edit3.Text + '" 1');  //  pdf-file and the 1 (=new file) are the parameters...
    fp := ExtractFilePath('"' + Edit3.Text + '"');    //  Set the directory/path where the pdf-file exists...
    lpDirectory := PChar(fp);
    nShow := SW_HIDE;                                 //  do not show/open the command line...
  end;
  if ShellExecuteEx(@SEInfo) then
    repeat
      Application.ProcessMessages;
      GetExitCodeProcess(SEInfo.hProcess, ExitCode);
    until (ExitCode <> STILL_ACTIVE) or Application.Terminated;
  Edit2.Text := IntToStr(ExitCode);                   //  the result. 0 or 9nnn are errors - 1 is success...
end;

procedure TForm1.Button6Click(Sender: TObject);
begin
  If OpenDialog1.Execute Then
     Edit1.Text := OpenDialog1.FileName;
end;

end.
