西西软件园多重安全检测下载网站、值得信赖的软件下载站!
软件
软件
文章
搜索

首页编程开发Delphi → 在Dlphi中添加删除ISAPI Filter实现代码

在Dlphi中添加删除ISAPI Filter实现代码

相关软件相关文章发表评论 来源:百度搜索时间:2011/8/1 11:32:41字体大小:A-A+

作者:佚名点击:53次评论:0次标签: Dlphi

  • 类型:反编译(译逆工程)大小:899KB语言:中文 评分:5.0
  • 标签:
立即下载
 function SplitString(Source,ch: String): TStringList;
var
temp:String;
i:Integer;
begin
Result:=TStringList.Create;
if Source = '' then Exit;
temp := Source;
i := pos(ch,Source);
while i <> 0 do
begin
Result.add(copy(temp,0,i-1));
Delete(temp,1,i);
i := pos(ch,temp);
end;
Result.add(temp);
end;

//Add a global IIS isapi filter
function AddISAPIFilterToIISGlobal(FilterName, FilterPath, FilterDesc:String):Boolean;
var
IISNameSpace,
IISWebService,
IISFilters,
IISFilter:Variant;
begin
Result := True;
try
try
IISNameSpace := CreateOleObject('IISNamespace');
IISWebService := IISNameSpace.GetObject('IIsWebService', 'localhost/w3svc');
IISFilters := IISWebService.GetObject('IISFilters', 'Filters');
IISFilters.FilterLoadOrder := IISFilters.FilterLoadOrder + ',' + FilterName;
IISFilters.SetInfo;
IISFilter := IISFilters.Create('IIsFilter',FilterName);
IISFilter.FilterPath := FilterPath;
IISFilter.FilterDescription := FilterDesc;
IISFilter.SetInfo;
except
Result := False;
end;
finally
IISFilter := Unassigned;
IISFilters := Unassigned;
IISWebService := Unassigned;
IISNameSpace := Unassigned;
end;
end;
//Add a isapi IIS filter to default web site
function AddISAPIFilterToIISDefaultSite(FilterName, FilterPath, FilterDesc:String):Boolean;
var
IISNameSpace,
IISWebService,
IISWebServer,
IISFilters,
IISFilter:Variant;
begin
Result := True;
try
try
IISNameSpace := CreateOleObject('IISNamespace');
IISWebService := IISNameSpace.GetObject('IISWebService', 'localhost/w3svc');
IISWebServer := IISWebService.GetObject('IISWebServer', '1');
IISFilters := IISWebServer.GetObject('IISFilters', 'Filters');
IISFilters.FilterLoadOrder := IISFilters.FilterLoadOrder + ',' + FilterName;
IISFilters.SetInfo;
IISFilter := IISFilters.Create('IISFilter',FilterName);
IISFilter.FilterPath := FilterPath;
IISFilter.FilterDescription := FilterDesc;
IISFilter.SetInfo;
except
Result := False;
end;
finally
IISFilter := Unassigned;
IISFilters := Unassigned;
IISWebService := Unassigned;
IISNameSpace := Unassigned;
end;
end;

function RemoveISAPIFilterFromIISGlobal(FilterName:String):Boolean;
var
IISNameSpace,
IISWebService,
IISFilters,
LoadOrder:Variant;
List:TStringList;
I:Integer;
begin
Result := True;
List := nil;
LoadOrder := '';
try
try
IISNameSpace := CreateOleObject('IISNamespace');
IISWebService := IISNameSpace.GetObject('IIsWebService', 'localhost/w3svc');
IISFilters := IISWebService.GetObject('IISFilters', 'Filters');
List := SplitString(IISFilters.FilterLoadOrder, ',');
for I := 0 to List.Count - 1 do
begin
if FilterName <> List[I] then
begin
if I <> List.Count - 1 then
LoadOrder := LoadOrder + List[I] + ','
else
LoadOrder := LoadOrder + List[I];
end;
end;
if IISFilters.FilterLoadOrder <> LoadOrder then
begin
IISFilters.FilterLoadOrder := LoadOrder;
IISFilters.SetInfo;
end;
IISFilters.Delete('IISFilters', FilterName);
except
Result := False;
end;
finally
LoadOrder := Unassigned;
IISFilters := Unassigned;
IISWebService := Unassigned;
IISNameSpace := Unassigned;
if List <> nil then
List.Free;
end;
end;
function RemoveISAPIFilterFromIISDefaultSite(FilterName:String):Boolean;
var
IISNameSpace,
IISWebService,
IISWebServer,
IISFilters,
LoadOrder:Variant;
List:TStringList;
I:Integer;
begin
Result := True;
List := nil;
LoadOrder := '';
try
try
IISNameSpace := CreateOleObject('IISNamespace');
IISWebService := IISNameSpace.GetObject('IIsWebService', 'localhost/w3svc');
IISWebServer := IISWebService.GetObject('IISWebServer', '1');
IISFilters := IISWebServer.GetObject('IISFilters', 'Filters');
List := SplitString(IISFilters.FilterLoadOrder, ',');
for I := 0 to List.Count - 1 do
begin
if FilterName <> List[I] then
begin
if I <> List.Count - 1 then
LoadOrder := LoadOrder + List[I] + ','
else
LoadOrder := LoadOrder + List[I];
end;
end;
if IISFilters.FilterLoadOrder <> LoadOrder then
begin
IISFilters.FilterLoadOrder := LoadOrder;
IISFilters.SetInfo;
end;
IISFilters.Delete('IISFilters', FilterName);
except
Result := False;
end;
finally
LoadOrder := Unassigned;
IISFilters := Unassigned;
IISWebServer := Unassigned;
IISWebService := Unassigned;
IISNameSpace := Unassigned;
if List <> nil then
List.Free;
end;
end;

    相关评论

    阅读本文后您有什么感想? 已有人给出评价!

    • 8 喜欢喜欢
    • 3 顶
    • 1 难过难过
    • 5 囧
    • 3 围观围观
    • 2 无聊无聊

    热门评论

    最新评论

    发表评论 查看所有评论(0)

    昵称:
    表情: 高兴 可 汗 我不要 害羞 好 下下下 送花 屎 亲亲
    字数: 0/500 (您的评论需要经过审核才能显示)