关于delphi 编写 isapi filter 利用IIS 过滤数据的问题,IIS5 和 IIS6的差异?IIS6运行不起来(100分)

  • 主题发起人 siyebocai
  • 开始时间
S

siyebocai

Unregistered / Unconfirmed
GUEST, unregistred user!
以下代码在IIS5中能运行,但是在IIS6中如果网页里有图片的话,图片就不显示了,过滤还是能实现的,请问什么原因,有何差异?!


library Project1;

{ Important note about DLL memory management: ShareMem must be the
first unit in your library's USES clause AND your project's (select
Project-View Source) USES clause if your DLL exports any procedures or
functions that pass strings as parameters or function results. This
applies to all strings passed to and from your DLL--even those that
are nested in records and classes. ShareMem is the interface unit to
the BORLNDMM.DLL shared memory manager, which must be deployed along
with your DLL. To avoid using BORLNDMM.DLL, pass string information
using PChar or ShortString parameters. }

uses
SysUtils,
Classes,
Windows,
variants,
Isapi4 in 'Isapi4.pas';


{$R *.res}
function GetFilterVersion(var pVer:THTTP_FILTER_VERSION):BOOL;stdcall;
begin
pVer.dwFlags:=(SF_NOTIFY_NONSECURE_PORT or SF_NOTIFY_SEND_RAW_DATA
or SF_NOTIFY_END_OF_REQUEST or SF_NOTIFY_ORDER_DEFAULT);

pVer.dwFilterVersion:=HTTP_FILTER_REVISION;
pVer.lpszFilterDesc[0]:='A';
pVer.lpszFilterDesc[1]:=#0;
result:=true;//初始化成功
end;

function HttpFilterProc(var pfc:THTTP_FILTER_CONTEXT;Notificationtype:DWORD;pvNotification:pointer):DWORD;stdcall;
var
p:pHTTP_FILTER_RAW_DATA;
i,tmpI:integer;
pc:pchar;
sList : TStringList;

f:textfile;//与TP中text类型相同
tmp:string;
Buffer,pszContent:pchar;
NewContent,OldContent:string;
begin


if Notificationtype=$80 then
//是SF_NOTIFY_END_OF_REQUEST将pFilterContext复位
begin
pfc.pFilterContext:=nil;
end
else
begin
p:=PHTTP_FILTER_RAW_DATA(pvNotification);
pc:=p^.pvInData;


try
OldContent:=pc;
//pszContent := PChar(@PChar(pfc.pFilterContext)[HeaderLen]);
NewContent:=stringreplace(OldContent,'123456','******',[rfReplaceAll]);
//NewContent:=OldContent;
Buffer := pfc.AllocMem(pfc, p^.cbInBuffer+1, 0);
ZeroMemory(Buffer,p^.cbInBuffer);
CopyMemory(Buffer, pchar(NewContent),length(NewContent));

with HTTP_FILTER_RAW_DATA(pvNotification^) do
begin
pvInData := Buffer;
cbInData := p^.cbInBuffer;
cbInBuffer := p^.cbInBuffer+1;
end;
except
on E: Exception do
begin
assignfile(f,'c:/tmp.txt');//TP中的assign
append(f);
writeln(f,pc);
writeln(f,e.Message);
closefile(f);
end;
end;


end;



result:=SF_STATUS_REQ_NEXT_NOTIFICATION;

end;


exports
GetFilterVersion,
HttpFilterProc;

begin
end.
 
有人做过吗?
 
有人做过吗?
 
顶部