在编译时没错。。运行时有错!错如上。
procedure TForm1.Button2Click(Sender: TObject);
var
  I: IADsContainer;  ADs: IADs;
begin
if ADsGetObject('IIS://localhost', IID_IADsContainer, IUnknown(I)) = S_Ok then begin //IIS已經安裝
    if ADsGetObject('IIS://localhost/w3svc', IID_IADsContainer, IUnknown(I)) = S_Ok then begin //Web伺服器存在
      ADs := IADs(I.GetObject('IIsWebServer', '1'));  //取得服務
      if ADs.QueryInterface(IID_IADsContainer, I) = S_OK then begin //服務支持
********下面的这句运行时出错!**********************************
        ADs := IADs(I.GetObject('001web', 'Root'));  //在Web伺服器的Root下建立虛擬目錄
********上面的这句运行时出错!********************************************
        if ADs.QueryInterface(IID_IADsContainer, I) = S_OK then begin //服務支持
          try
            ADs := IADs(I.Create('001web', '001web')); //建立虛擬目錄,別名為edtAlias.Text
          except
            Application.MessageBox('這個別名已經存在,請選擇另外的別名!','警告');
            Exit;
          end; //try except
          Application.MessageBox('您的設定已經保存。','恭喜');
        end;
      end;
    end;
  end else
    Application.MessageBox('您的電腦上沒有安裝IIS或者您無權訪問IIS。','警告');
end;