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
/*-----------------------------------------------------------------------------*/
/*-----------------------------------------------------------------------------*/
/*-----------------------------------------------------------------------------*/
/*-----------------------------------------------------------------------------*/