写的比较匆忙,应该满足你了,自己多加些判断就可以了,不过10分也太多了点,我还凌晨帮你写代码呢[
][
]
关键是蓝色部分
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, OleCtrls, SHDocVw;
type
TForm1 = class(TForm)
WebBrowser1: TWebBrowser;
procedure WebBrowser1BeforeNavigate2(Sender: TObject;
const pDisp: IDispatch; var URL, Flags, TargetFrameName, PostData,
Headers: OleVariant; var Cancel: WordBool);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.WebBrowser1BeforeNavigate2(Sender: TObject;
const pDisp: IDispatch; var URL, Flags, TargetFrameName, PostData,
Headers: OleVariant; var Cancel: WordBool);
begin
Caption := URL;
[blue]if Pos('.rar', URL) >0 then begin // 判断是不是有.rar
if Pos('.rar', Url)= Length(URL) -3 then begin // 判断是不是rar在最后
Cancel := True
end;
end[/blue] else
Cancel := False;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
WebBrowser1.Navigate('http://www.2ccc.com/article.asp?articleid=1116');
end;
end.