Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Window Mgmt Insu. Array convertion
Message
 
 
To
13/08/2005 23:11:20
General information
Forum:
Visual FoxPro
Category:
Visual FoxPro and .NET
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows 2000 SP4
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01040674
Message ID:
01040755
Views:
23
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--
Previous
Reply
Map
View

Click here to load this message in the networking platform