unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,unitwjshook,
StdCtrls,registry;
type
TForm1 = class(TForm)
Button1: TButton;
Label1: TLabel;
ComboBox1: TComboBox;
ComboBox2: TComboBox;
Edit1: TEdit;
Label2: TLabel;
Edit2: TEdit;
procedure Button1Click(Sender: TObject);
procedure FormClose(Sender: TObject;
var Action: TCloseAction);
procedure FormShow(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
procedure StartHook(FileBeSpy,readfile,writefile
char);
stdcall;external 'ComTSRDLL';
procedure StopHook;
stdcall;external 'ComTSRDLL';
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var
FileRead,FileWrite:string;
begin
if button1.caption='开始' then
begin
button1.caption:='停止';
FileRead:=edit1.text;
FileWrite:=edit2.text;
deletefile(FileRead);
deletefile(FileWrite);
StartHook(Pchar(combobox1.text),pchar(FileRead),pchar(FileWrite));
end
else
begin
StopHook;
button1.caption:='开始';
end;
end;
procedure TForm1.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
if button1.caption<>'开始' then
Button1Click(Sender);
end;
procedure TForm1.FormShow(Sender: TObject);
var
reg:tregistry;
i:integer;
begin
reg:=tregistry.create;
reg.RootKey:=HKEY_LOCAL_MACHINE;
reg.openkey('System/CurrentControlSet/Services/Class/Modem/',true);
reg.GetKeyNames(combobox2.items);
reg.closekey;
for i:=0 to combobox2.items.count-1 do
begin
reg.openkey('System/CurrentControlSet/Services/Class/Modem/'+combobox2.items
,true);
if reg.ValueExists('model') then
combobox1.items.add('//./'+reg.ReadString('model'));
reg.closekey;
end;
reg.free;
combobox1.itemindex:=1;
end;
end.