unit uMain;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ShellAPI, Grids;

type
  TfrmSetDriveType = class(TForm)
    btnStart: TButton;
    btnStop: TButton;
    Button1: TButton;
    procedure btnStartClick(Sender: TObject);
    procedure btnStopClick(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmSetDriveType: TfrmSetDriveType;

implementation

{$R *.dfm}

const
  DLL_NAME = 'APIHook.dll';

procedure StartHook; stdcall; external DLL_NAME;

procedure StopHook; stdcall; external DLL_NAME;

procedure TfrmSetDriveType.btnStartClick(Sender: TObject);
begin
  StartHook;
  btnStart.Enabled := False;
  btnStop.Enabled := True;
end;

procedure TfrmSetDriveType.btnStopClick(Sender: TObject);
begin
  StopHook;
  btnStart.Enabled := True;
  btnStop.Enabled := False;
end;

procedure TfrmSetDriveType.Button1Click(Sender: TObject);
begin
  MessageBox(0,'a','b',0);
end;

procedure TfrmSetDriveType.FormClose(Sender: TObject; var Action: TCloseAction);
var i:char;
    ts:string;
begin
  if btnStop.Enabled then btnStop.Click;
end;

initialization

finalization
  StopHook;
end.


