program MDXWin_FastLoader;

uses
  Windows, Messages, SysUtils, ShellAPI;

{$R *.res}

procedure SendCopyData(wnd:hwnd;Mes:string);
var
  CDS:TCopyDataStruct;
begin
  CDS.cbData:=Length(Mes)+1;
  CDS.lpData:=pchar(Mes);
  SendMessage(Wnd,WM_COPYDATA,0,LongInt(@CDS));
end;

procedure MDXWinBoot;
var
  Filename,Param:string;
begin
  Filename:=ExtractFilePath(ParamStr(0))+'MDXWin.exe';
  if ParamCount=0 then
    Param:=''
    else
    Param:='"'+ParamStr(1)+'"';
  ShellExecute(0,'open',PChar(Filename),pchar(Param), nil,SW_SHOW);
end;

var
  Title:string;
  Wnd:hwnd;
begin
  Title:='MDXWin 2.xx';
  Wnd:=FindWindow('TMain',pchar(Title));
  if Wnd=0 then begin
    MDXWinBoot;
    end else begin
    if ParamCount=0 then exit;
    if copy(ParamStr(1),1,2)='\\' then exit;
    if copy(ParamStr(1),1,1)<>'/' then SendCopyData(wnd,ParamStr(1));
  end;
end.
