unit mainform;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls,shellapi;

type
  TExternalOptions = class(TForm)
    lbIni: TListBox;
    setIniGo: TButton;
    remoteGo: TButton;
    procedure FormCreate(Sender: TObject);
    procedure setIniGoClick(Sender: TObject);
    procedure remoteGoClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  ExternalOptions: TExternalOptions;

implementation

{$R *.dfm}

procedure TExternalOptions.FormCreate(Sender: TObject);
var
searchResult : TSearchRec;
begin
  if FindFirst('c:\empathy\AltIni\*.ini', faAnyFile, searchResult) = 0 then
  begin
    repeat
      lbIni.Items.Add(searchResult.Name);
    until FindNext(searchResult) <> 0;
  FindClose(searchResult);
  end;
end;

procedure TExternalOptions.remoteGoClick(Sender: TObject);
begin
 ShellExecute(Handle, 'open', pchar('c:\windows\system32\cmd.exe'), nil, nil, SW_SHOWNORMAL);
 ShellExecute(Handle, 'open', pchar('c:\program files\tightvnc\tvnserver.exe'), pchar(' -controlservice -connect idc.librarysmith.co.uk'), nil, SW_SHOWNORMAL);
 //ShellExecute(Handle, 'open', pchar('c:\empathy\matthew-remote-help.exe'), nil, nil, SW_SHOWNORMAL);
end;

procedure TExternalOptions.setIniGoClick(Sender: TObject);
begin
if lbIni.ItemIndex<0 then exit;
if (messagedlg('Set ini file to '+lbIni.items[lbIni.ItemIndex]+' and relaunch?',mtConfirmation,[mbYes,mbNo],0)=mrYes) then begin
  Winapi.Windows.copyfile(PWideChar('c:\empathy\AltIni\'+lbIni.items[lbIni.ItemIndex]),'c:\empathy\empathy.ini',false);
  ShellExecute(Handle, 'open', pchar('c:\empathy\empathy.exe'), nil, nil, SW_SHOWNORMAL);
  application.Terminate;
end;
end;




end.