您现在的位置:首页 >> API >> API >> 内容

Delphi中添加删除ISAPI Filter

时间:2011/9/3 15:44:53 点击:

  核心提示:function SplitString(Source,ch: String): TStringList; var temp:String; i:Integer; begin Result:=TStr...
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;

上一页12下一页

Tags:添加 删除 
作者:网络 来源:转载
共有评论 0相关评论
发表我的评论
  • 大名:
  • 内容:
本类推荐
  • 没有
本类固顶
  • 没有
  • 盒子文章(www.2ccc.com) © 2022 版权所有 All Rights Reserved.
  • 沪ICP备05001939号