Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

IEnumString - how to use?

303 views
Skip to first unread message

Jerry F. Davis

unread,
Nov 22, 1999, 3:00:00 AM11/22/99
to
I have need to be able to create and use an IEnumString.

What is such a beast, and just how do I create one and use it?

Jerry


ASH

unread,
Nov 23, 1999, 3:00:00 AM11/23/99
to
A good place to start is MSDN to find out about IEnumXXXX in the
section dealing with all things COM. They enable you to enumerate
through collections of things (in this case strings).

Generally you won't need to implement this interface as it is usually
passed by some other COM object for you to use.

Implementing it yourself is not a simple matter, however, Delphi might
have done it for you already.

Note that I have not tried the following.
uses AXCtrls

var
S: TStrings;
OS: IStrings;
EnumString: TStringsEnumerator; { implements IEnumString }
begin
S := TStringList.Create;
try
GetOLEStrings(S, OS);
EnumString := TStringsEnumerator.Create(OS);
{ Use the EnumString Obj as required - you will need to
QueryInterface to get a ref to IEnumString }
finally
EnumString.Free;
S.Free;
end;
end;

If this doesn't work try copying all the code in TStringsEnumerator to
your own strings enumerator object, and change it to inherit from
TInterfacedObject instead of TContainedObject.

Let me know if it works - good luck

> I have need to be able to create and use an IEnumString.
>
> What is such a beast, and just how do I create one and use it?


Sent via Deja.com http://www.deja.com/
Before you buy.

Deborah Pate

unread,
Nov 23, 1999, 3:00:00 AM11/23/99
to
<<Jerry F. Davis:

I have need to be able to create and use an IEnumString.

What is such a beast, and just how do I create one and use it?
>>

This is the declaration in the ActiveX unit.

{$EXTERNALSYM IEnumString}
IEnumString = interface(IUnknown)
['{00000101-0000-0000-C000-000000000046}']
function Next(celt: Longint; out elt;
pceltFetched: PLongint): HResult; stdcall;
function Skip(celt: Longint): HResult; stdcall;
function Reset: HResult; stdcall;
function Clone(out enm: IEnumString): HResult; stdcall;
end;

It's one of a group of IEnum interfaces, which are basically
the COM way of passing collections as parameters - the
Next function returns S_OK while the sender has more
items in the collection to send, S_False if it doesn't.

Have a look at the TStringsEnumerator class in AxCtrls.pas
which implements this interface.

Deborah Pate

0 new messages