unit Unit2;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ComCtrls, ShellCtrls, ExtCtrls, Buttons, Menus,
        ShlObj, ComObj, ActiveX,registry;

type
  TForm2 = class(TForm)
    GroupBox1: TGroupBox;
    Button1: TButton;
    ShellListView1: TShellListView;
    Timer1: TTimer;
    BitBtn1: TBitBtn;
    PopupMenu1: TPopupMenu;
    xcvzxcv1: TMenuItem;
    vmbnmvbmn1: TMenuItem;
    N1: TMenuItem;
    OpenDialog1: TOpenDialog;
    SaveDialog1: TSaveDialog;
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
    procedure BitBtn1MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure ShellListView1MouseMove(Sender: TObject; Shift: TShiftState;
      X, Y: Integer);
    procedure GroupBox1MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure N1Click(Sender: TObject);
    procedure xcvzxcv1Click(Sender: TObject);
    procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);

  private
    { Private declarations }

  public
    { Public declarations }
  end;

var
  Form2: TForm2;
    sPath: String[60];
     j:boolean;
implementation

{$R *.dfm}


procedure TForm2.FormCreate(Sender: TObject);
begin
  GetDir(0,sPath);
  shelllistview1.Root:=sPath+'\icon1\';
 savedialog1.InitialDir:=sPath+'\icon1\';
form2.Height :=80;
form2.Width:=120;
end;

procedure TForm2.Button1Click(Sender: TObject);
begin
close;
end;

procedure TForm2.Timer1Timer(Sender: TObject);
begin
if j=true then begin j:=false;bitbtn1.Font.Color:=clRed;
 end else begin j:=true; bitbtn1.Font.Color:=clblue; end
end;

procedure TForm2.BitBtn1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
 form2.Height :=362;
 form2.Width :=220;
 bitbtn1.Visible :=false;
 shelllistview1.Visible :=true;
 end;

procedure TForm2.ShellListView1MouseMove(Sender: TObject;
  Shift: TShiftState; X, Y: Integer);
begin
if (3>y) or (3>x) or (356<=y) or (180=x)then
begin
form2.Height :=80;
form2.Width:=120;
bitbtn1.Visible :=true;
shelllistview1.Visible :=false;
end;
end;

procedure TForm2.GroupBox1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
const
  SC_DragMove = $F012;  { a magic number }
begin
  ReleaseCapture;
  form2.perform(WM_SysCommand, SC_DragMove, 0);

end;

procedure TForm2.N1Click(Sender: TObject);
begin
close;
end;

procedure TForm2.xcvzxcv1Click(Sender: TObject);
var
  MyObject: IUnknown;
  MyIcon: IShellLink;
  MyPFile: IPersistFile;
  FileName: string;
  Directory: string;
  WFileName: WideString;
  MyReg: TRegIniFile;

begin
  GetDir(0,sPath);
if OpenDialog1.Execute then
if SaveDialog1.Execute then
  MyObject := CreateComObject(CLSID_ShellLink);
  MyIcon := MyObject as IShellLink;
  MyPFile := MyObject as IPersistFile;
  FileName := opendialog1.FileName;
  with MyIcon do
  begin
    SetArguments(PChar(opendialog1.FileName));
    SetPath(PChar(opendialog1.FileName));
    SetWorkingDirectory(PChar(ExtractFilePath(FileName)));
  end;
  MyReg :=
    TRegIniFile.Create('Software\MicroSoft\Windows\CurrentVersion\Explorer');
  Begin
  Directory := spath+'\icon1\';
  End;

  WFileName := SaveDialog1.FileName+'.lnk';
  MyPFile.Save(PWChar(WFileName), False);
  MyReg.Free;
  end;

procedure TForm2.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
 form2.Height :=80;
form2.Width:=120;
bitbtn1.Visible :=true;
shelllistview1.Visible :=false;
end;
end.

