Delphi中用Adsi创建IIS虚拟目录的方法
|
源代码网整理以下先引入类型库(Project|Import Type Library)adsiis.dll、iisext.dll和activeds.tlb新建一个单元,声明。 源代码网整理以下unit ActiveDs; 软件开发网 www.mscto.com 源代码网整理以下 interface 源代码网整理以下 function ADsGetObject(const PathName: WideString; const GUID: 软件开发网 www.mscto.com 源代码网整理以下 TGUID; out I: IUnknown): HRESULT; stdcall; 源代码网整理以下 implementation 源代码网整理以下 function ADsGetObject; external "activeds.dll" name "ADsGetObject"; 源代码网整理以下 end. 源代码网整理以下 源代码网整理以下var 源代码网整理以下 I: IADsContainer; 软件开发网 www.mscto.com 源代码网整理以下 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); 软件开发网 www.mscto.com 源代码网整理以下 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; 源代码网整理以下 源代码网整理以下procedure TForm3.BitBtn4Click(Sender: TObject); 源代码网整理以下 var 源代码网整理以下 Disp: IDispatch; 源代码网整理以下 begin 软件开发网 www.mscto.com
源代码网整理以下 Disp := IISNamespace1.GetObject("IIsWebService", "localhost/w3svc"); 源代码网整理以下 Disp := (Disp as IADsContainer).GetObject("IIsWebServer", "1"); 源代码网整理以下 Disp := (Disp as IADsContainer).GetObject("IIsWebVirtualDir", "Root"); 源代码网整理以下 Disp := (Disp as IADsContainer).Create("IIsWebVirtualDir", "DelphiADSITest"); 软件开发网 www.mscto.com 源代码网整理以下 (Disp as IADs).Put("AccessRead", "True"); 源代码网整理以下 (Disp as IADs).Put("Path", "c:ADSITest"); 源代码网整理以下 (Disp as IADs).SetInfo; 源代码网整理以下 end; 源代码网推荐 源代码网供稿. |
