WMIService() : Destroy() ?

WMIService() : Destroy() ?

Postby Jimmy » Thu Nov 14, 2019 3:35 am

hi,

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

Question : how to "destroy" WMI Connection ?

Code: Select all  Expand view  RUN
  oLocator := CreateObject( "wbemScripting.SwbemLocator" )
   oWMI := oLocator:ConnectServer()
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1733
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: WMIService() : Destroy() ?

Postby Antonio Linares » Thu Nov 14, 2019 6:23 am

Try with:

oWMI := nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42125
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: WMIService() : Destroy() ?

Postby Jimmy » Thu Nov 14, 2019 7:06 pm

hi ,
Antonio Linares wrote:Try with:
oWMI := nil

Thx for Answer.

Code: Select all  Expand view  RUN
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
User avatar
Jimmy
 
Posts: 1733
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Danielmaximiliano and 36 guests