WMI / FOR EACH / does "Property" Exist ?

WMI / FOR EACH / does "Property" Exist ?

Postby Jimmy » Tue Jun 13, 2023 4:27 am

hi,

i use WMI to ask for some Hardware Information like RAM

Code: Select all  Expand view
  FOR EACH oMemory IN oWmi:ExecQuery( "SELECT * FROM Win32_PhysicalMemory" )
       nSumRAM += VAL( oMemory:Capacity )
       cFormFactor := GetFormFaktorText( oMemory:FormFactor )
       cMemoryType := GetRAMtype( oMemory:SMBIOSMemoryType )

       // ask for "SPEED"
       IF __ObjHasData( oMemory, "SPEED" )
       IF __ObjHasMethod( oMemory, "SPEED" )

both IF __Obj* give me .F. :?

but this work
Code: Select all  Expand view
      cSpeed := oMemory:Speed
       cSpeed := oMemory:GETPROPERTY("SPEED")


Problem : it does not work on every PC
if i use TRY / CATCH / END than line after Error will not execute

so how to "ask" in FOR EACH if a "Property" Exist :?:
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1725
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: WMI / FOR EACH / does "Property" Exist ?

Postby nageswaragunupudi » Tue Jun 13, 2023 1:13 pm

__ObjHasData and __ObjHasMethod work only with Harbour classes.

if i use TRY / CATCH / END than line after Error will not execute


Suggested:
Code: Select all  Expand view

TRY
  speed := o:Speed
CATCH
  speed := 0
END
? speed
 


so how to "ask" in FOR EACH if a "Property" Exist

FOR EACH works with Harbour Arrays and objects only.

Can you please share with us how are you now doing this with HMG, to help me to learn more about this subject?
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10624
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: WMI / FOR EACH / does "Property" Exist ?

Postby Jimmy » Tue Jun 13, 2023 4:51 pm

hi,

thx for Answer

under Xbase++ "Property" aof COM/ActiveX are same as Member VAR (DATA)
Eigenschaft (engl.: Property)
Instanzvariable einer COM/ActiveX-Komponente, entspricht einer Membervariablen (IVar) eines Xbase++-Objektes.

thats why i try __ObjHasData but fail

-

Code: Select all  Expand view
  TRY
      a := 1
      b := 1/0
      c := "not execute"
   CATCH
      FWLOG a,b,c
   END

as "b" gave a Error Line with "c" will not be execute
i have to use it for every "Property" to CATCH Error
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1725
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: WMI / FOR EACH / does "Property" Exist ?

Postby nageswaragunupudi » Tue Jun 13, 2023 4:58 pm

i have to use it for every "Property" to CATCH Error

Yes.
Better we make a function with TRY/CATCH
under Xbase++ "Property" aof COM/ActiveX are same as Member VAR (DATA)

That's nice. Good to know.
What about HMG?
ps: I am asking because I never used them
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10624
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: WMI / FOR EACH / does "Property" Exist ?

Postby Jimmy » Tue Jun 13, 2023 5:15 pm

hi,
nageswaragunupudi wrote:What about HMG?
ps: I am asking because I never used them

i did not know __Obj* Function until Antonio told me so i have not use it under HMG
i will ask in HMG Forum if they have a Solution
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1725
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 96 guests