• Welcome to Theos PowerBasic Museum 2017.

IWshCollection.NewEnum_ Method

Started by José Roca, July 14, 2008, 10:49:54 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

José Roca



The following code illustrates the use of the NewEnum_ method:


#INCLUDE "WSHOM.INC"

DIM pWsh AS IWshShell
DIM pSpecialFolders AS IWshCollection
DIM pUnk AS IUnknown
DIM nCount AS LONG
DIM i AS LONG
DIM vValue AS VARIANT

pWsh = NEWCOM "WScript.Shell"

' Get a reference to the special folders collection
pSpecialFolders = pWsh.SpecialFolders

' Get the number of objects in the collection
nCount = pSpecialFolders.Count

' Get a reference to the collection's enumerator
pUnk = pSpecialFolders.NewEnum_
pEnum = pUnk

' Enumerates the collection
FOR i = 0 TO nCount - 1
   pEnum.Next 1, vValue, celtFetched
   IF celtFetched = 0 THEN EXIT FOR
   STDOUT VARIANT$(vValue)
NEXT