WMIService() : Destroy() ?

Post Reply
User avatar
Jimmy
Posts: 165
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

WMIService() : Destroy() ?

Post by Jimmy »

hi,

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

Question : how to "destroy" WMI Connection ?

Code: Select all

   oLocator := CreateObject( "wbemScripting.SwbemLocator" )
   oWMI := oLocator:ConnectServer()
greeting,
Jimmy
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: WMIService() : Destroy() ?

Post by Antonio Linares »

Try with:

oWMI := nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Jimmy
Posts: 165
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: WMIService() : Destroy() ?

Post by Jimmy »

hi ,
Antonio Linares wrote:Try with:
oWMI := nil
Thx for Answer.

Code: Select all

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
Post Reply