Create an IIS virtual directory with ADSI in Delphi

zhaozj2021-02-08  263

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 a method (refer to 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 (IisWebject ('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; Method 2 (using interface), procedure tform3.bitbtn4click (sender: TOBJECT) VAR DISP: Idispatch; Begin Disp: = Iisnamespace1.GetObject ('IisWebService'); DISP: = (DISP As IadsContainer); DISWEBSERVER ',' 1 '); DISP: = (DISP as IADsContainer) .GetObject ( 'IIsWebVirtualDir', 'Root'); Disp: = (Disp as IADsContainer) .Create ( 'IIsWebVirtualDir', 'DelphiADSITest'); (Disp as IADs) .Put ( 'AccessRead', 'True' ); (DISP AS IADS) .PUT ('Path', 'C: / Aditest'); (DISP AS IADS) .SetInfo; End; Method 3 (using Variant,

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

New Post(0)