Criação de DLL e Uso
Enviado: 30 Jan 2012 09:48
cdll.prg
cdll.hbp
cdll.bat (para gerar a dll)
Testar a DLL
testedll.prg
Para compilar:
Código: Selecionar todos
DYNAMIC Alert
function Another()
cVar:="teste"
Alert( "Inside the DLL" )
return cVar
function Teste(cVar)
cVar:="passagem por referencia"
return cVar
Código: Selecionar todos
#---------------------------
# Nome da DLL
# ---------------------------
-ocdll
# ---------------------------
# Bibliotecas
# ---------------------------
-lhbmaindllp
# ---------------------------
# Outros Parƒmetros
# ---------------------------
#-workdir=.\OBJ\
-hbdyn
# ---------------------------
# Prg(s) e Rc(s)
# ---------------------------
CDLL.PRG
Código: Selecionar todos
@echo off
set path=d:\harbour32\bin
SET HB_COMPILER=mingw
hbmk2 cdll.hbp
pause
testedll.prg
Código: Selecionar todos
function Main()
local hDLL := hb_LibLoad( "cdll.dll" )
cTeste1:=""
cTeste:=Do( "Another" )
Alert(cTeste)
Do( "Teste",@cTeste1)
Alert( cTeste1 )
hb_LibFree( hDLL )
return nil
#pragma BEGINDUMP
#include "hbapi.h"
HB_EXPORT_ATTR PHB_FUNC dll_hb_vmProcAddress( const char * szFuncName )
{
return hb_vmProcAddress( szFuncName );
}
#pragma ENDDUMP
Código: Selecionar todos
set hb_compiler=mingw
hbmk2 testedll.prg