FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour WMIService() : Destroy() ?
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM
WMIService() : Destroy() ?
Posted: Thu Nov 14, 2019 03:35 AM
hi,

i saw WMI Sample which use Function WMIService()
x:\fwh\samples\pcinfo.prg

Question : how to "destroy" WMI Connection ?

Code (fw): Select all Collapse
   oLocator := CreateObject( "wbemScripting.SwbemLocator" )
   oWMI := oLocator:ConnectServer()
greeting,

Jimmy
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: WMIService() : Destroy() ?
Posted: Thu Nov 14, 2019 06:23 AM

Try with:

oWMI := nil

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM
Re: WMIService() : Destroy() ?
Posted: Thu Nov 14, 2019 07:06 PM
hi ,
Antonio Linares wrote:Try with:
oWMI := nil

Thx for Answer.

Code (fw): Select all Collapse
function WMIService()
   // It would be useful to keep this function in the library
   static oWMI
   local oLocator

   if oWMI == nil
      oLocator   := CREATEOBJECT( "wbemScripting.SwbemLocator" )
      oWMI       := oLocator:ConnectServer()
   endif
return oWMI

how got get to that STATIC :-)
what about ActiveX oLocator :-)

i just think i have to destroy it else those Connection stay open (under Xbase++). i don't know how it is in harbour.
greeting,

Jimmy

Continue the discussion