如何拦截广告(弹出窗口和页面内的) 给你一个控件,你email地址呢? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 unit IExplorerCounter;interfaceuses Messages, ExtCtrls, Windows, SysUtils, Classes;type TIExplorer = class(TComponent) private FMaxWindow : Integer; FOpenWindow : Integer; WindowsList : Array of HWND; Title : Array[0..512] of Char; Timer : TTimer; FEnabled : Boolean; procedure SetEnabled(Value: Boolean); procedure SetMaxWindow(Value: Integer); procedure OnTimer (Sender: TObject); public constructor Create(AOwner: TComponent); override; destructor Destroy; override; property OpenWindows : Integer read FOpenWindow default 0; published property MaxWindows : Integer read FMaxWindow write SetMaxWindow; property Enabled : Boolean read FEnabled write SetEnabled; end;procedure Register;implementationprocedure Register;begin RegisterComponents('Internet', [TIExplorer]);end;function EnumWindowsCallback(hwnd: HWND; lParam: LPARAM): BOOL; stdcall;var Explorer: TIExplorer;begin Explorer := TIExplorer(LParam); if GetWindowText(hwnd, Explorer.Title, SizeOf(Explorer.Title)) > 0 then begin if pos('microsoft internet explorer', lowercase(Explorer.Title)) > 0 then begin if Explorer.FOpenWindow >= Explorer.FMaxWindow then begin { Kill Previous windows } PostMessage(Explorer.WindowsList[0], WM_CLOSE,0,0); { Kill window } move(Explorer.WindowsList[1], Explorer.WindowsList[0], Explorer.FOpenWindow-1); Explorer.WindowsList[Explorer.FOpenWindow-1] := hwnd; end else begin inc(Explorer.FOpenWindow); Explorer.WindowsList[Explorer.FOpenWindow-1] := hwnd; end; end; end; Result := true; if Explorer.FEnabled then Explorer.Timer.Enabled := true;end;procedure TIExplorer.OnTimer (Sender: TObject);begin Timer.Enabled := false; FOpenWindow := 0; EnumWindows(@EnumWindowsCallback, LPARAM(self));end;constructor TIExplorer.Create(AOwner: TComponent);begin inherited Create(AOwner); FMaxWindow := 2; Setlength(WindowsList, FMaxWindow); Timer := TTimer.Create(nil); Timer.Enabled := false; Timer.OnTimer := OnTimer; Timer.Interval := 100;end;destructor TIExplorer.Destroy;begin SetLength(WindowsList, 0); inherited Destroy;end;procedure TIExplorer.SetMaxWindow(Value: Integer);begin if Value <> FMaxWindow then begin SetLength(WindowsList, Value); FMaxWindow := Value; end;end;procedure TIExplorer.SetEnabled(Value: Boolean);begin if FEnabled <> Value then begin FEnabled := Value; Timer.Enabled := Value; end;end;end. 我的意思是不想使用检测窗口标题的方式,这种方式太浪费资源目前我使用的是方式是作为IE的插件,监听IE的事件,在打开新窗口之前判断是否为广告窗口。没有一个比较好的方式。还有页面里面的Banner, 全屏幕的Flash 也没有办法 能否将里面的SQL语句转换成delphi里面能用的语句?大家帮帮忙~ 帮忙 如何取得Treeview 节点ID 数据显示的问题---韩文显示 怎样把comboBox里的数据存到数据库? 关于timer的简单问题 我的249个字段,这对操作有影响吗? 菜鸟问题…… delphi 6.0系列号哪里有?? ADO连接Access2000数据库的问题 如何使用“Dephi”编写动态连接库? 如何响应COMBOBOX的下拉选项关闭时的消息
interfaceuses
Messages, ExtCtrls, Windows, SysUtils, Classes;type TIExplorer = class(TComponent)
private
FMaxWindow : Integer;
FOpenWindow : Integer;
WindowsList : Array of HWND;
Title : Array[0..512] of Char;
Timer : TTimer;
FEnabled : Boolean;
procedure SetEnabled(Value: Boolean);
procedure SetMaxWindow(Value: Integer);
procedure OnTimer (Sender: TObject);
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
property OpenWindows : Integer read FOpenWindow default 0;
published
property MaxWindows : Integer read FMaxWindow write SetMaxWindow;
property Enabled : Boolean read FEnabled write SetEnabled;
end;procedure Register;implementationprocedure Register;
begin
RegisterComponents('Internet', [TIExplorer]);
end;function EnumWindowsCallback(hwnd: HWND; lParam: LPARAM): BOOL; stdcall;
var
Explorer: TIExplorer;
begin
Explorer := TIExplorer(LParam); if GetWindowText(hwnd, Explorer.Title, SizeOf(Explorer.Title)) > 0 then
begin
if pos('microsoft internet explorer', lowercase(Explorer.Title)) > 0 then
begin
if Explorer.FOpenWindow >= Explorer.FMaxWindow then
begin { Kill Previous windows }
PostMessage(Explorer.WindowsList[0], WM_CLOSE,0,0); { Kill window } move(Explorer.WindowsList[1], Explorer.WindowsList[0], Explorer.FOpenWindow-1);
Explorer.WindowsList[Explorer.FOpenWindow-1] := hwnd;
end
else
begin
inc(Explorer.FOpenWindow);
Explorer.WindowsList[Explorer.FOpenWindow-1] := hwnd;
end;
end;
end;
Result := true;
if Explorer.FEnabled then
Explorer.Timer.Enabled := true;
end;procedure TIExplorer.OnTimer (Sender: TObject);
begin
Timer.Enabled := false;
FOpenWindow := 0;
EnumWindows(@EnumWindowsCallback, LPARAM(self));
end;constructor TIExplorer.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FMaxWindow := 2;
Setlength(WindowsList, FMaxWindow);
Timer := TTimer.Create(nil);
Timer.Enabled := false;
Timer.OnTimer := OnTimer;
Timer.Interval := 100;
end;destructor TIExplorer.Destroy;
begin
SetLength(WindowsList, 0);
inherited Destroy;
end;procedure TIExplorer.SetMaxWindow(Value: Integer);
begin
if Value <> FMaxWindow then
begin
SetLength(WindowsList, Value);
FMaxWindow := Value;
end;
end;procedure TIExplorer.SetEnabled(Value: Boolean);
begin
if FEnabled <> Value then
begin
FEnabled := Value;
Timer.Enabled := Value;
end;
end;
end.
目前我使用的是方式是作为IE的插件,监听IE的事件,在打开新窗口之前判断
是否为广告窗口。没有一个比较好的方式。
还有页面里面的Banner, 全屏幕的Flash 也没有办法