西西軟件園多重安全檢測下載網(wǎng)站、值得信賴的軟件下載站!
軟件
軟件
文章
搜索

首頁編程開發(fā)Delphi → 在Dlphi中添加刪除ISAPI Filter實現(xiàn)代碼

在Dlphi中添加刪除ISAPI Filter實現(xiàn)代碼

相關(guān)軟件相關(guān)文章發(fā)表評論 來源:百度搜索時間:2011/8/1 11:32:41字體大。A-A+

作者:佚名點擊:53次評論:0次標(biāo)簽: Dlphi

  • 類型:反編譯(譯逆工程)大。899KB語言:中文 評分:5.0
  • 標(biāo)簽:
立即下載
 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;

    相關(guān)評論

    閱讀本文后您有什么感想? 已有人給出評價!

    • 8 喜歡喜歡
    • 3 頂
    • 1 難過難過
    • 5 囧
    • 3 圍觀圍觀
    • 2 無聊無聊

    熱門評論

    最新評論

    發(fā)表評論 查看所有評論(0)

    昵稱:
    表情: 高興 可 汗 我不要 害羞 好 下下下 送花 屎 親親
    字?jǐn)?shù): 0/500 (您的評論需要經(jīng)過審核才能顯示)