Chamando GZIP da DLL

Aqui você poderá oferecer suas Contribuições, Dicas e Tutoriais (Texto ou Vídeo) que sejam de interesse de todos.

Moderador: Moderadores

Avatar do usuário
JoséQuintas
Administrador
Administrador
Mensagens: 20415
Registrado em: 26 Fev 2007 11:59
Localização: São Paulo-SP
Curtiram: 1 vez

Chamando GZIP da DLL

Mensagem por JoséQuintas »

Foi só um teste que fiz, pra tentar ajudar em uso no xharbour.
O Harbour já tem isso, não precisa de dll.

Criei a função genérica de chamadas desse tipo de dll (o normal pra API Windows é HB_DYN_CALL_CONV_STD)

Código: Selecionar todos

#include "hbdyn.ch"
FUNCTION CallDllCDecl( cDll, cName, ... )

   LOCAL hDll, xResult

   hDll    := hb_LibLoad( cDll )
   xResult := hb_DynCall( { cName, hDll, HB_DYN_CALLCONV_CDECL }, ... )
   hb_LibFree( hDll )

   RETURN xResult
A função intermediária pra GZIP

Código: Selecionar todos

FUNCTION GZip( cTextInput )

   LOCAL cTextOutput, nLenInput, nLenOutput

   nLenInput := Len( cTextInput )
   nLenOutput := nLenInput + 5000
   cTextOutput := Space( nLenOutput )

   CallDllCDecl( "zlib1.dll", "compress", @cTextOutput, @nLenOutput, cTextInput, nLenInput, 6 )

   RETURN Left( cTextOutput, nlenOutput )
E o uso normal

Código: Selecionar todos

PROCEDURE Main

   SetMode(33,100)
   CLS
   ? gzip( "test" )
   Inkey(0)

   RETURN

No caso do xharbour, é encontrar o equivalente de chamadas de DLL tipo CDECL (sei lá o que é isso)
Dependendo da finalidade, talvez adicionar hb_Base64Encode( cResultado )
José M. C. Quintas
Harbour 3.2, mingw, multithread, gtwvg, fivewin 25.12, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui), (hmg3), (hmg extended), (oohg), PNotepad, ASP, (Linux/Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"

https://github.com/JoseQuintas/
Responder