{

  SPECIAL THANKS TO:
  Positron (CPL Code)
  Faceless Wonder (EditServer Code)


  ========================================================================
  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful, but
  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT-
  ABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
  Public License for more details.
  ========================================================================


  *******Stealth Redirector Version 2.0 Source Code*******


  ########   ENGLISH   ########

  >>>>>COMPILING WARNING<<<<<
  For compile this project you need installed the Indy Components Version 9.0.0.14!
  This version is compiled with Delphi 6 Personal Update Pack 2.

  The output file format is a .cpl Control Panel Applet.


  For ANY question please post it in my forum: http://sourceforge.net/forum/?group_id=86409
  registration is NOT REQUIRED, ANONYMOUS ALLOWED.

  ########   ITALIANO   #######

  >>>>>NECESSARIO PER COMPILARE<<<<<
  Per compilare questo progetto è necessario avere installato il package "Indy Components" versione 9.0.0.14!
  Questa versione è stata compilata con Delphi 6 Personal Update Pack 2.

  Il file compilato ha estensione .cpl ed è interpretata come una applicazione del pannello di controllo.
  Viene eseguita come un normale .exe (doppio click).


  Per QUALSIASI problema vi prego di postare nel mio forum: http://sourceforge.net/forum/?group_id=86409
  la registrazione al forum non è necessaria.



  Created by Tia86

  for new versions visit http://sourceforge.net/projects/myredirect

  RELEASED UNDER THE TERMS OF GNU GENERAL PUBLIC LICENSE (GPL)

}
library StealthRed;

uses
  Windows,   CPL ,forms,

  Unit1 in 'Unit1.pas' {TRedirector};


{$E cpl}
{$R redirector.res}

const   APPLETS_COUNT = 1;




procedure RunRedirector;               //run the main code of Stealth Redirector
begin
//Redirector := TRedirector.Create(nil);     //only for debug
//Redirector.ShowModal;                      //only for debug

Application.Initialize;
Application.CreateForm(TRedirector,Redirector);
Application.ShowMainForm:= False;
Application.Run;
end;

function CPlApplet(hWndCPL : hWnd;
                   iMessage : integer;
                   lParam1 : longint;
                   lParam2 : longint) : LongInt stdcall;
begin

  case iMessage of

    CPL_INIT : begin //first message, sent only once
      //this is the time to create global objects

      Result := 1;
      exit;
    end;

    CPL_GETCOUNT : begin //second message sent once to get number of applets

      Result := APPLETS_COUNT; //returning number of dialog boxes supported
      exit;
    end;

    CPL_INQUIRE : begin


      //lParam1 is the zero based Dialog Box, or Applet number...
      //lParam2 is a CPLINFO record to be filled now...

      //this message will be sent once for every dialog supported i.e. the
      //value returned in CPL_GETCOUNT...

      //Filling in the CPLINFO record with resource information...
      //NOTE that we wrote our resource file with ID cleverly so
      //as to make the code based on the dialog number, see cp_resource.rc

      //the name that will show under the icon in Control Panel
      PCplInfo(lParam2)^.idName := (10 * (lParam1 + 1)) + 0;
      //the string that will show in the status bar of Control Panel when this
      //icon is chosen
      PCplInfo(lParam2)^.idInfo := (10 * (lParam1 + 1)) + 1;
      //the icon that will show in Control Panel for this dialog
      PCplInfo(lParam2)^.idIcon := (10 * (lParam1 + 1)) + 2;
      //this would be the area to store specific information, which could be
      //used later in the CPL_DBLCLK, CPL_STOP, CPL_STARTWPARMS.  Not used
      //for this project, so zero
      PCplInfo(lParam2)^.lData := 0;

      //if need to allocate any memory for the specific dialog as indicated by
      //lParam1, this would be the place to do it...
      Result := 0; //handled, returning zero
      exit;
    end;

    CPL_NEWINQUIRE : begin

      //see remarks in CPL_INQUIRE.  Everything is the same, except lParam2
      //represents a NEWCPLINFO record instead of CPLINFO record.

      PNewCplInfo(lParam2)^.dwSize := sizeof(TNewCplInfo);
      PNewCplInfo(lParam2)^.lData := 0;

      //get the icon
      PNewCplInfo(lParam2)^.IconH := LoadIcon(hInstance,
                            MakeIntResource((10 * (lParam1 + 1)) + 2));
      //get the title
      LoadString(hInstance,
                (10 * (lParam1 + 1)) + 0,
                @PNewCplInfo(lParam2)^.szName,
                sizeof(PNewCplInfo(lParam2).szName));

      //get the description
      LoadString(hInstance,
                (10 * (lParam1 + 1)) + 1,
                @PNewCplInfo(lParam2)^.szInfo,
                sizeof(PNewCplInfo(lParam2).szInfo));

      //not used in this project, so set to zero
      PNewCplInfo(lParam2)^.dwHelpContext := 0;
      PNewCplInfo(lParam2)^.szHelpFile[0] := #0;

      Result := 0;
      exit;

    end;

    CPL_SELECT : begin
      Result := 0;
      exit;
    end;
    CPL_DBLCLK : begin
                  
                 RunRedirector;    // run Stealth Redirector
                 Result := 0;
                  exit;
                 end;
    CPL_STOP : begin
       Redirector.Free;
      Result := 0;
      exit;
    end;
    CPL_EXIT : begin

      Result := 0;
      exit;

    end;


    CPL_STARTWPARAMS : begin
      Result := 1;
      exit;
    end;

    else begin
      Result := 0;
      exit;
    end;
  end;
end;

//as required export CPLApplet by name
exports CPlApplet name 'CPlApplet';

begin
end.






