• Welcome to Powerbasic Museum 2020-B.
 

News:

Forum in repository mode. No new members allowed.

Main Menu

IWshEnvironment.length Property

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

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

José Roca



The following code illustrates the use of the length property:


#INCLUDE "WSHOM.INC"

DIM pWsh AS IWshShell
DIM pWshEnv AS IWshEnvironment
DIM nLen AS LONG
DIM pUnk AS IUnknown
DIM pEnum AS IEnumVARIANT
DIM IID_IEnumVARIANT AS GUID
DIM i AS LONG
DIM celtFetched AS LONG
DIM vValue AS VARIANT

' Create an instance of Windows Script Host
pWsh = NEWCOM "WScript.Shell"
' Get a reference to environment collection
pWshEnv = pWsh.Environment
' Get the number of objects in the collection
nLen = pWshEnv.length
' Get a reference to the collection's enumerator
pUnk = pWshEnv.NewEnum_
pEnum = pUnk
FOR i = 0 TO nLen - 1
  pEnum.Next 1, vValue, celtFetched
  IF celtFetched = 0 THEN EXIT FOR
  STDOUT VARIANT$(vValue)
NEXT