Solved

Help with _newenum

Posted on 2001-06-07
4
692 Views
Last Modified: 2007-11-27
I am trying to enum the virtual webservers in the iiswebservice object. Basically (for each website in webservice) in VB. I am trying to do this in Delphi 5.

WebSite := CreateOleObject('IISNamespace');
        WebSite := WebSite.GetObject('IIsWebService', 'localhost/w3svc');
        Enum := website._newenumm as ienumvariant;

I can not get this to work. I was hoping someone here could shed some light.

Thanks in advance.
John Lindsly
0
Comment
Question by:jtl12
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 6

Expert Comment

by:edey
ID: 6164553
I found this article: http://www.techvanguards.com/com/tutorials/tips.asp#Know%20how%20to%20implement%20clients%20that%20iterate%20IEnumVARIANT-based%20collections

Here's a snippet:

uses ComLib;

var
  Foo : IFoo;
  Item : olevariant;
  Enum : TEnumVariant;
begin
  Foo := CreateOleObject ('FooServer.Foo') as IFoo;  //or CoFoo.Create
  Enum := TEnumVariant.Create (Foo.Items);
  while (Enum.ForEach (Item)) do
    DoSomething (Item);
  Enum.Free;
end;

Note, I'm not sure what is contained in ComLib, but it's available (freely) from the authors website (see the above link).

GL
Mike
0
 

Author Comment

by:jtl12
ID: 6164572
Yea I have this code snippet. However iiswebservice does not appear to have an items prop. So I do not know how to apply this to my case.

Thanks for your help though
0
 
LVL 6

Expert Comment

by:edey
ID: 6164930
Hi, i really wish I could give more specific help, but i don't have IIS. At any rate I did find the following from a usenet article:

procedure TMainForm.btnListClick(Sender: TObject);
var
  ADsContainer: IADsContainer;
  EnumVariant : IEnumVariant;
  Child       : OleVariant;
  Fetched     : LongWord;
  ADSIPath    : WideString;
begin
  Lst.Clear;

  ADSIPath := 'IIS://localhost/W3SVC/1/ROOT';
  OleCheck(ADsGetObject(PWideChar(ADSIPath), IADsContainer, ADsContainer));

  // A Delphi For Each loop!
  EnumVariant := ADsContainer._NewEnum as IEnumVariant;
  EnumVariant.Reset;
  Fetched := 0;
  while Succeeded(EnumVariant.Next(1, Child, Fetched)) and (Fetched > 0) do
    Lst.Items.Add(Child.Name);
end;


perhaps it may shed some light on the issue.

GL
Mike
0
 
LVL 26

Accepted Solution

by:
Russell Libby earned 100 total points
ID: 6165120

I did not forget you from yesterday, I just didn't have the free until now.

So....

const
  IID_IADSContainer:   TGUID =  '{001677D0-FD16-11CE-ABC4-02608C9E7553}';

type
  IADSContainer  =  interface(IDispatch)
     ['{001677D0-FD16-11CE-ABC4-02608C9E7553}']
     function    get_Count(out plCount: Longint): HResult; stdcall;
     function    get__NewEnum(out ppEnumerator: IEnumVariant): HResult; stdcall;
     function    get_Filter(const pvFilter: Variant): HResult; stdcall;
     function    put_Filter(out pvFilter: Variant): HResult; stdcall;
     function    get_Hints(const pvHints: Variant): HResult; stdcall;
     function    put_Hints(out pvHints: Variant): HResult; stdcall;
     function    GetObject(const bstrClass, bstrRelativeName: WideString; out ppNamedObject: IDispatch): HResult; stdcall;
     function    Create(const bstrClass, bstrRelativeName: WideString; out ppNamedObject: IDispatch): HResult; stdcall;
     function    Delete(const bstrClass, bstrRelativeName: WideString): HResult; stdcall;
     function    CopyHere(const bstrSource, bstrNew: WideString; out ppNamedObject: IDispatch): HResult; stdcall;
     function    MoveHere(const bstrSource, bstrNew: WideString; out ppNamedObject: IDispatch): HResult; stdcall;
  end;

var
  Form1: TForm1;

implementation
{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
var  oNameSpace: OleVariant;
     piac:       IADSContainer;
     oService:   OleVariant;
     oSite:      OleVariant;
     oServer:    OleVariant;
     oBindings:  OleVariant;
     oComputer:  OleVariant;
     pev:        IEnumVariant;
     s:          String;
begin

  CoInitialize(nil);

  oNameSpace:=CreateOleObject('IISNamespace');
  oService:=oNameSpace.GetObject('IIsWebService', 'localhost/w3svc');
  IDispatch(oService).QueryInterface(IADSContainer, piac);
  if piac.get__NewEnum(pev) = S_OK then
  begin
     pev.Reset;
     while pev.Next(1, oServer, nil) = S_OK do
     begin
        s:=oServer.Class;
        if CompareText(s, 'IIsWebServer') = 0 then
        begin
           // Check the server comment to the name
           // your looking for, like "Default Web Site"
           ShowMessage(oServer.ServerComment);
        end;
     end;
  end;

end;
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Magic Software info 18 156
How to load 2 images in same column in Delphi 2 82
How to save the image in the .cds File ClientDataSet? 1 42
shape, triangle, dbctrlgrid 3 47
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question