delphi中用adsi创建IIS虚拟目录......
先引入类型库(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;