Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Window Mgmt Insu. Array convertion
Message
 
 
À
13/08/2005 23:11:20
Information générale
Forum:
Visual FoxPro
Catégorie:
Visual FoxPro et .NET
Versions des environnements
Visual FoxPro:
VFP 9
OS:
Windows 2000 SP4
Database:
Visual FoxPro
Divers
Thread ID:
01040674
Message ID:
01040755
Vues:
21
I don't know if there is direct way to convert WMI array to VFP array but following code seems to do the job.
lcClass = "Win32_Printer"
oWMI = GETOBJECT("winmgmts:")
oItems = oWMI.ExecQuery("select * from " + lcClass)


FOR EACH oItem IN oItems
	oClass = oItem
	EXIT
NEXT

oItem = CREATEOBJECT("empty")

FOR EACH oProperty IN oClass.Properties_

	cName = oProperty.NAME

	IF oProperty.IsArray
		lnItems = 1
		DIMENSION vArray[1]
		*? cName 
		TRY
			FOR lnItems=1 TO 999
				DIMENSION vArray[lnItems]
				vArray[lnItems] = oProperty.VALUE[lnItems-1]
				*? lnItems, vArray[lnItems]
			ENDFOR
		CATCH TO oExp WHEN oExp.ERRORNO = 1426 ;
				AND (UPPER("Does not support a collection") $ UPPER(oExp.MESSAGE))
			vArray[lnItems] = oProperty.VALUE

		CATCH TO oExp WHEN oExp.ERRORNO = 1426 ;
				AND ("INVALID INDEX" $ UPPER(oExp.MESSAGE))
			lnItems = lnItems - 1
			DIMENSION vArray[lnItems]
		ENDTRY

		ADDPROPERTY(oItem, cName + "[1]" )
		=ACOPY(vArray, oItem.&cName)

	ELSE
		vValue = oProperty.VALUE
		ADDPROPERTY(oItem, cName, vValue)
	ENDIF

ENDFOR
>code as under
>
<snip>
>
>I Collect Info some WMI Calss.
--sb--
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform