Create an IIS virtual directory with ADSI in Delphi

xiaoxiao2021-03-06  39

Create an IIS virtual directory with ADSI in Delphi

2004-5-15 2:17:21 (Article Category: Delphi)

First introduced a type library (Project | Import Type Library) adsiis.dll, iisext.dll and activeds.tlb create a new unit, the statement 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. Method 1 (Refer to C ), Vari: IadsContainer; ADS: Iads; Begin If AdsGetObject ('IIS: // localhost / w3svc', IID_IADSCONTAINER, IUNKNOWN (I)) = S_OK THENBEGIN ADS: = IADS (I.GetObject ('IisWebserver', '1')); SHOWMESSAGE Ads.adspath); IF ads.queryinterface (IID_IADSCONTAINER, I) = S_OK TEN begin ads: = IADS (I.GetObject ('IisWebVirtualdir', 'root')); SHOWMESSAGE (ADS) .Adspath); IF ads.queryinterface (IID_IADSCONTAINER, I) = S_OK TEN BEGIN ads: = IADS (I.create ('IisWebVirtualdir', 'delphitest'));  Ads.put ('AccessRead', 'True'); ads.put ('Path', 'C: / Temp'); ads.setinfo; hend; nd; Hend; End; Method 2 (using interface), procedure tform3.bitbtn4click (sender: TOBJECT); vardisp: idispatch; begindisp: = Iisnamespace1.Getobj ECT ('IisWebservice'); disp: = (DISP AS IADSCONTAINER) .GETOBJECT ('IisWebServer', '1'); disp: = (DISP AS IADSCONTAINER) .GETOBJECT ('IisWebVirtualdir', 'Root'); disp: = (DISP as Iadscontainer) .create ('DelphiaDsitest');  (DISP AS IADS) .put ('AccessRead', 'True');  (DISP AS IADS) .Put ('Path', 'c: / adsitest');  (DISP AS IADS) .SetInfo; End; Method 3 (using variant, is a method similar to VB and ASP), Procedure TFORM2.bitbtn1click (Sender: TOBJECT) Varwebsite, WebServer, Webroot, Vdir: Variant;

转载请注明原文地址:https://www.9cbs.com/read-68331.html

New Post(0)