Chilkat's ActiveX

Chilkat's ActiveX

Postby hua » Fri May 10, 2024 9:27 am

Hi
Some of you guys have used Chilkat's ActiveX DLL before so I want to ask how to end its object
e.g.
Code: Select all  Expand view  RUN
local oHttp = CreateObject('Chilkat_9_5_0.Http')
local oReq = CreateObject('Chilkat_9_5_0.HttpRequest')
 

Do I have to do a oHttp:end() and oReq:end() or there's no need for that as once local vars are out of scope the object will be automatically terminated?

TIA
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
hua
 
Posts: 1072
Joined: Fri Oct 28, 2005 2:27 am

Re: Chilkat's ActiveX

Postby karinha » Fri May 10, 2024 11:24 am

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7831
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Chilkat's ActiveX

Postby Giovany Vecchi » Fri May 10, 2024 6:24 pm

Hello.
You declare the objects as Nil and the Garbage harbor system will automatically unload them if they do not have memory links.
oHttp := Nil
oReq := Nil

To terminate the Chilkat control Handle initiated by the GLOBAL Resource use Method FinalizeThreadPool()

The prg below is used for initializing and closing the dll.

Code: Select all  Expand view  RUN
#Include "FiveWin.ch"

STATIC st_lChilkatOk, st_oChilKatObject

FUNCTION TCHILKAT_GLOBAL_CHECA()
   Local lc_lOk                           := .F.
   Local lc_aRetStart                     := {}

   If Hb_IsNil(st_lChilkatOk)
      lc_aRetStart := TCHILKAT_GLOBAL_START()
      If !lc_aRetStart[1]
         MsgStop(lc_aRetStart[2],"Procedimento abortado.")
      Else
         lc_lOk := .T.  
      EndIf
   Else
      lc_lOk := .T.
   EndIf

RETURN lc_lOk
///////////////////////////////////////////////////////////////////////////////
FUNCTION TCHILKAT_GLOBAL_START()
   Local lc_oGlobal
   Local lc_lOk                           := .F.
   Local cRetClass                        := ""

   if !IsActiveX("Chilkat_9_5_0.Global.1")
      RegisterServer("ChilkatAx-9.5.0-win32.dll")
      IF !IsActiveX("Chilkat_9_5_0.Global.1")
         RETURN {.F.,"Componente ChilKat não esta registrado"}
      ENDIF
   endif
 
   lc_oGlobal := tChilKat_Global():New()
   if lc_oGlobal:lActiveX
      lc_lOk := lc_oGlobal:tChilKat_Global_UnlockBundle()
   EndIf
   cRetClass := lc_oGlobal:cRetorno
   st_oChilKatObject := lc_oGlobal

   st_lChilkatOk := lc_lOk

RETURN {lc_lOk,cRetClass}
///////////////////////////////////////////////////////////////////////////////
EXIT PROCEDURE TCHILKAT_GLOBAL_CLOSE()
 
   //? "Fechar handle global"

   If Hb_IsNil(st_lChilkatOk)
      st_lChilkatOk := .F.
   EndIf
 
   If st_lChilkatOk
      st_oChilKatObject:oGlobal:FinalizeThreadPool()
      st_lChilkatOk := .F.
   EndIf

RETURN

/*-----------------------------------------------------------------------------*/
Class tChilKat_Global

   Data cCLSID                            As String      init "Chilkat_9_5_0.Global.1" //Id da classe Global de Chilkat
   Data oGlobal                           As Object
   Data lActiveX                          As Logic       Init .F.       //Se a classe cClSID esta funcionando em ActiveX
   Data lUnlocked                         As Logic       Init .F.       //Se o recurso global de Chilkat esta habilitado conforme
                                                                        //  a chave de registro em UnlockBundle
   Data lInstaled                         As Logic      Init .F.         //Se a DLL esta instalada e registrada com RegisterServer
   Data cRetorno                          As String      Init ""        //Texto de retorno informativo
 
   Method New() Constructor
   Method End()

   Method tChilKat_Global_UnlockBundle()

EndClass
/*-----------------------------------------------------------------------------*/
Method New() Class tChilKat_Global

   TRY
      ::oGlobal     := ToleAuto():New( ::cCLSID )
   CATCH
      ::lInstaled := .F.
   END
 
   If Hb_isNil(::oGlobal)
      ::lActiveX  := .F.
      ::cRetorno  := "Chilkat não registrado"
   Else
      ::lActiveX := .T.
      ::cRetorno  := "Chilkat registrado"
   EndIf

Return Self
/*-----------------------------------------------------------------------------*/
Method End() Class tChilKat_Global

Return Nil
/*-----------------------------------------------------------------------------*/
Method tChilKat_Global_UnlockBundle() Class tChilKat_Global

   ::lUnlocked := (::oGlobal:UnlockBundle("??????.???????_????????????") == 1)
   
   If ::lUnlocked
      ::cRetorno := "Recurso registrado e destravado"
   Else
      ::cRetorno := "Recurso registrado porem travado"
   EndIf

Return ::lUnlocked
/*-----------------------------------------------------------------------------*/
/*-----------------------------------------------------------------------------*/
/*-----------------------------------------------------------------------------*/
/*-----------------------------------------------------------------------------*/
User avatar
Giovany Vecchi
 
Posts: 223
Joined: Mon Jun 05, 2006 9:39 pm
Location: Brasil

Re: Chilkat's ActiveX

Postby hua » Sun May 12, 2024 5:16 pm

Thank you very much Giovany
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
hua
 
Posts: 1072
Joined: Fri Oct 28, 2005 2:27 am


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 72 guests