• Welcome to Theos PowerBasic Museum 2017.

News:

Attachments are only available to registered users.
Please register using your full, real name.

Main Menu

PowerBasic or Visual Basic?

Started by James McNab, September 06, 2010, 04:55:22 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Chris Boss

I have the second edition of the book!

Meaning it was edited to deal with 32 bit code.

Don Dickinson

Jose posted a link above to a wmi safe array example: http://www.jose.it-berater.org/smfforum/index.php?board=229.0
that link doesn't seem to work anymore. is there an updated link or other sample code somewhere?
tia,
don

Theo Gottwald

PB 10 has builtin support for Safearrays.
Why use WMI for that?

Don Dickinson

sorry should have mentioned i'm not using pb10 for this particular (legacy code) project.

José Roca

The only use of safearrays with WMI that I remember was not an example but a discussion. See: http://www.jose.it-berater.org/smfforum/index.php?topic=806.msg1669#msg1669

Don Dickinson

Thanks for the reply Jose. Unfortunately when i click that link i get a message:
"The topic or board you are looking for appears to be either missing or off limits to you."

José Roca

Well, the relevant code is


' // After getting the safe array in a variant (vRes)...
LOCAL pvar AS VARIANTAPI PTR
pvar = VARPTR(vRes)

LOCAL plLBound, plUBound, ix AS LONG
LOCAL vValue AS VARIANT
hr = SafeArrayGetLBound(@pvar.vd.parray, 1, plLBound)
hr = SafeArrayGetUBound(@pvar.vd.parray, 1, plUBound)
FOR i = plLBound TO plUBound
   ix = i
   SafeArrayGetElement(@pvar.vd.parray, ix, vValue)
   MSGBOX VARIANT$(vValue)
NEXT


The use of SafeArrayGetElement depends on how have you it declared.