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

Delphi中添加删除ISAPI Filter(2)

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

  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;

上一页12下一页

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