打印本文 打印本文 关闭窗口 关闭窗口
Delphi中用Adsi创建IIS虚拟目录
作者:武汉SEO闵涛  文章来源:敏韬网  点击数921  更新时间:2009/4/23 18:24:49  文章录入:mintao  责任编辑:mintao
   先引入类型库(Project|Import Type Library)adsiis.dll、iisext.dll和activeds.tlb新建一个单元,声明。
unit ActiveDs;

interface

 function ADsGetObject(const PathName: WideString; const GUID:

TGUID; out I: IUnknown): HRESULT; stdcall;

implementation

 function ADsGetObject;   external 'activeds.dll' name 'ADsGetObject';

end.

方法一(参照C++)、

var

 I: IADsContainer;

 ADs: IADs;

begin

 if ADsGetObject('IIS://localhost/w3svc', IID_IADsContainer, IUnknown(I)) = S_Ok then

 begin

  ADs := IADs(I.GetObject('IIsWebServer', '1'));

  ShowMessage(ADs.ADsPath);

  if ADs.QueryInterface(IID_IADsContainer, I) = S_OK then

  begin

   ADs := IADs(I.GetObject('IIsWebVirtualDir', 'Root'));

   ShowMessage(ADs.ADsPath);

   if ADs.QueryInterface(IID_IADsContainer, I) = S_OK then

   begin

    ADs := IADs(I.Create('IIsWebVirtualDir', 'DelphiTest'));

    ADs.Put('AccessRead', 'True');

    ADs.Put('Path', 'c:\Temp');

    ADs.SetInfo;

   end;

  end;

 end;

end;

打印本文 打印本文 关闭窗口 关闭窗口