Delphi中用Adsi创建IIS虚拟目录的方法

Delphi中用Adsi创建IIS虚拟目录的方法,第1张

Delphi中用Adsi创建IIS虚拟目录的方法,第2张

引入类型库(project | import type library)adsiis.dll、iisext.dll和activeds.tlb创建一个新单元并声明。

单位活动;
接口
函数ADsGetObject(const PathName:WideString;const GUID:
TGUID;out I:I unknown):HRESULT;stdcall
实现
函数ADsGetObject外部“activeds.dll”名称为“ads getobject”;
结束。

方法一(参考c++)var
I:iads container;
ADs:IADs;
begin
if ADs GetObject(' IIS://localhost/w3sVC ',IID_IADsContainer,IUnknown(I)) = S_Ok然后
begin
ADs:= IADs(I . GetObject(' IIS web server ',' 1 '));
ShowMessage(ADs。ADsPath);
如果广告。query interface(IID _ IADs container,I) = S_OK然后
begin
ADs:= IADs(I . GetObject(' IIS webvirtualdir ',' Root '));
ShowMessage(ADs。ADsPath);
如果广告。query interface(IID _ IADs container,I) = S_OK然后
begin
ADs:= IADs(I . Create(' IIsWebVirtualDir ',' Delphi test ');
广告。Put('AccessRead ',' True ');
广告。Put('Path ',' c:\ Temp ');
广告。SetInfo
end;
end;
end;
end;


方法二(使用接口)proceduretform 3 . bitbtn 4 click(sender:to object);
var
Disp:IDispatch;
begin
Disp:= IIS namespace 1。GetObject('IIsWebService ',' localhost/w3svc ');
Disp:=(Disp as iads container)。GetObject('IIsWebServer ',' 1 ');
Disp:=(Disp as iads container)。GetObject('IIsWebVirtualDir ',' Root ');
Disp:=(Disp as iads container)。Create('IIsWebVirtualDir ',' Delphi adsitest ');
(显示为IADs)。Put('AccessRead ',' True ');
(显示为IADs)。Put('Path ',' c:\ ADSITest ');
(显示为IADs)。SetInfo
end;


方法三(使用Variant,类似于VB和ASP的方法)proceduretform 2 . bit btn1 click(sender:to object);
var
WebSite,WebServer,WebRoot,VDir:Variant;
begin
WebSite:= create ole object(' IIS namespace ');
网址:=网址。GetObject('IIsWebService ',' localhost/w3svc ');
WebServer :=网站。GetObject('IIsWebServer ',' 1 ');
WebRoot := WebServer。GetObject('IIsWebVirtualDir ',' Root ');
VDir := WebRoot。Create('IIsWebVirtualDir ',' variant test ');
VDir。access read:= True;
VDir。path:= ' C:\ Test ';
VDir。SetInfo
end;

位律师回复
DABAN RP主题是一个优秀的主题,极致后台体验,无插件,集成会员系统
白度搜_经验知识百科全书 » Delphi中用Adsi创建IIS虚拟目录的方法

0条评论

发表评论

提供最优质的资源集合

立即查看 了解详情