Página 1 de 1
eh possivel usar dll com clipper ?
Enviado: 19 Nov 2008 15:02
por Trazom
estou procurando solucao para gerar os tais arquivos xml da nf-e, por enquanto encontrei uma dll que permite faze-lo com facilidade
mas tem como usar dll em clipper, como usar rundll32 ?
Re: eh possivel usar dll com clipper ?
Enviado: 19 Nov 2008 15:08
por Maligno
Usar a RUNDLL32 é possível em clipper, já que ela executa em linha de comando. Use o comando RUN ou a função SwpRunCmd() do BLinker.
Re: eh possivel usar dll com clipper ?
Enviado: 19 Nov 2008 19:25
por alxsts
Boas!
Sei que é possível criar uma serie de rotinas em Clipper e, através do Blinker, gerar uma DLL. Depois, de outro executável Clipper, ligado, tambem pelo Blinker, à DLL criada, executar aquelas rotinas. Segue código de exemplo retirado de:
http://www.karland.com/code/clipper/ (BLDLL.ZIP)
Não sei se é possível gerar, pelo BLinker, um executável Clipper que referencia uma DLL criada por outro programa. Enfim, é uma boa pergunta. Vamos testar?
[]s
AlxSts
Código: Selecionar todos
Blinker 4.00 DLL's
I recently received Blinker 4.00 and have been running some initial tests.
I thought I would share some of my findings on the new .DLL functions.
There are two ways of using .DLL's in extended mode Clipper programs.
Note: .DLL's cannot be used in dual or real mode programs.
(1) The .DLL is created and the included functions are made known to the
main program at link time.
With this method the .DLL is static, i.e. it has to be decided at
forehand which functions will be placed in the .DLL and the main
program needs to be linked after the .DLL file.
-------------------------------------------------------------------------
MYDLL.PRG (clipper program to by linked to a .dll)
-------------------------------------------------------------------------
FUNC FUNC1()
RETU ( "We are testing function 1" )
FUNC FUNC2()
RETU ( "We are testing function 2" )
-------------------------------------------------------------------------
MYDLL.LNK (link file for the .DLL)
-------------------------------------------------------------------------
BLINKER EXECUTABLE EXTENDED # extended mode program
FILE mydll # name of the .prg file
OUTPUT mydll # name of the .dll file
FILE bldclp52 # CA-Clipper 5.2 DLL handler for each DLL
DEFBEGIN
LIBRARY mydll # name of the .dll file
EXPORTS
FUNC1 # function called by main program
FUNC2 # function called by main program
# ... # (add all functions here)
DEFEND
NODEFLIB
-------------------------------------------------------------------------
Create the .DLL file
-------------------------------------------------------------------------
CL mydll (compile)
BLINKER @MYDLL (link)
BLILIB /ID mydll /OL mydll (create .dll definition file)
-------------------------------------------------------------------------
MYEXE.PRG (clipper program to by linked to a .exe)
-------------------------------------------------------------------------
FUNC MAIN()
CLS
@ 0,0 SAY "We are now testing .dll functions"
@ 1,0 SAY FUNC1()
@ 2,0 SAY FUNC2()
RETU ( NIL )
-------------------------------------------------------------------------
Link file for the .EXE (MYEXE.LNK)
-------------------------------------------------------------------------
BLINKER EXECUTABLE EXTENDED
FILE myexe # name of the .prg file
OUTPUT myexe # name of the .exe file
LIB mydll # the .dll definition file
FILE blxclp52 # CA-Clipper 5.2 DLL handler for main EXE
SEARCH blxclp52 # CA-Clipper 5.2 protected mode library
LIB clipper
LIB extend
LIB terminal
LIB dbfntx
-------------------------------------------------------------------------
Create the .EXE file
-------------------------------------------------------------------------
CL myexe (compile)
BLINKER @MYEXE (link)
(2) The .DLL is created and the included functions are not known to the
main program at link time. The main program uses blinker functions
to load the .DLL at run time.
With this method the .DLL is dynamic, i.e. if the main program is
notified (through a database for example) new functions can be added
for updated versions of the .DLL file.
-------------------------------------------------------------------------
MYDLL.PRG (clipper program to by linked to a .dll)
-------------------------------------------------------------------------
FUNC FUNC1()
RETU ( "We are testing function 1" )
FUNC FUNC2()
RETU ( "We are testing function 2" )
-------------------------------------------------------------------------
MYDLL.LNK (link file for the .DLL)
-------------------------------------------------------------------------
BLINKER EXECUTABLE EXTENDED # extended mode program
BLINKER EXECUTABLE NODELETE # don't worry about unresolved externals
# i.e. main program functions called by the
# .dll
FILE mydll # name of the .prg file
OUTPUT mydll # name of the .dll file
FILE bldclp52 # CA-Clipper 5.2 DLL handler for each DLL
DEFBEGIN
LIBRARY mydll # name of the .dll file
EXPORTS
FUNC1 # function called by main program
FUNC2 # function called by main program
# ... # (add all functions here)
DEFEND
NODEFLIB
-------------------------------------------------------------------------
Create the .DLL file
-------------------------------------------------------------------------
CL mydll (compile)
BLINKER @MYDLL (link)
-------------------------------------------------------------------------
MYEXE.PRG (clipper program to by linked to a .exe)
-------------------------------------------------------------------------
FUNC MAIN()
LOCA nLhan, nFhan
CLS
@ 0,0 SAY "We are now testing .dll functions"
nLhan := BLILIBLOD("mydll") // load the .dll and get a handle
IF nLhan > 32 // check for valid handle
nFhan := BLIFUNHAN(nLhan, "FUNC1") // get function handle FUNC1()
// NOTE: must be upper case
IF !nFhan == 0 // check for valid handle
// NOTE: contrary to the manual
// valid handles can be
// negative
@ 1,0 SAY BLIFUNCAL(nFhan)
// NOTE: If parameters are passed to the function they go before
// the function handle as in
// BLIFUNCAL(nPara1, nPara2, nFhan)
ENDI
nFhan := BLIFUNHAN(nLhan, "FUNC2") // NOTE: must be upper case
IF !nFhan == 0
@ 2,0 SAY BLIFUNCAL(nFhan)
ENDI
BLILIBFRE(nLhan) // free the dynamically loaded .dll
ENDI
RETU ( NIL )
-------------------------------------------------------------------------
Link file for the .EXE (MYEXE.LNK)
-------------------------------------------------------------------------
BLINKER EXECUTABLE EXTENDED
FILE myexe # name of the .prg file
OUTPUT myexe # name of the .exe file
FILE blxclp52 # CA-Clipper 5.2 DLL handler for main EXE
SEARCH blxclp52 # CA-Clipper 5.2 protected mode library
LIB clipper
LIB extend
LIB terminal
LIB dbfntx
-------------------------------------------------------------------------
Create the .EXE file
-------------------------------------------------------------------------
CL myexe (compile)
BLINKER @MYEXE (link)
Re: eh possivel usar dll com clipper ?
Enviado: 19 Nov 2008 19:33
por Maligno
Mas a pergunta do colega não é sobre como criar DLL, mas sobre como ele poderia utilizar uma DLL já existente, que ele quer para resolver um problema com XML. Observe.
Re: eh possivel usar dll com clipper ?
Enviado: 19 Nov 2008 20:10
por alxsts
Caros amigos,
Maligno escreveu: ...Mas a pergunta do colega não é sobre como criar DLL, mas sobre como ele poderia utilizar uma DLL já existente...
observem que no código que depositei na janela código, existem os exemplos de como criar e como utilizar:
Código: Selecionar todos
-------------------------------------------------------------------------
MYEXE.PRG (clipper program to by linked to a .exe)
-------------------------------------------------------------------------
FUNC MAIN()
LOCA nLhan, nFhan
CLS
@ 0,0 SAY "We are now testing .dll functions"
nLhan := BLILIBLOD("mydll") // load the .dll and get a handle
IF nLhan > 32 // check for valid handle
nFhan := BLIFUNHAN(nLhan, "FUNC1") // get function handle FUNC1() ] NOTE: must be upper case
IF !nFhan == 0 // check for valid handle
// NOTE: contrary to the manual
// valid handles can be
// negative
@ 1,0 SAY BLIFUNCAL(nFhan)
// NOTE: If parameters are passed to the function they go before the function handle as in BLIFUNCAL(nPara1, nPara2, nFhan)
ENDIF
nFhan := BLIFUNHAN(nLhan, "FUNC2") // NOTE: must be upper case
IF !nFhan == 0
@ 2,0 SAY BLIFUNCAL(nFhan)
ENDI
BLILIBFRE(nLhan) // free the dynamically loaded .dll
ENDIF
RETU ( NIL )
Não testei isto. Bom feriado para todos.
[]s
AlxSts
-------------------------------
Nota de Moderação (Toledo): mensagem editada para colocar a tag [ code ]
Veja como utilizar esta tag: faq.php?mode=bbcode#f21
Re: eh possivel usar dll com clipper ?
Enviado: 21 Nov 2008 13:08
por sygecom
Acredito que as DLL para rodarem no clipper tem que esta em 16bits.
Re: eh possivel usar dll com clipper ?
Enviado: 21 Nov 2008 14:23
por Maligno
A resposta é simples: se a DLL mencionada pelo OP for de uma linguagem qualquer que não o Clipper, não é possível utilizá-la diretamente. Óbvio. Sendo 32 bits, é possível usar o programa RUNDLL32 (comando RUN ou SwpRunCmd()), dependendo do que for preciso executar. Mas se ela foi feita em Clipper, pelo BLinker, é possível usá-la diretamente.