Creating a LIB or DLL

Re: Creating a LIB or DLL

Postby Antonio Linares » Tue Oct 07, 2014 11:27 pm

Creo que ahora he entendido mejor lo que preguntabas.

Puesto que pasas de PRG a C, pierdes las variables por referencia. Salvo que la variable por referencia se convierta en un puntero a la variable.

Prueba asi:

Code: Select all  Expand view

HB_EXPORT char * PASCAL _export HBDLLSTRING5( char * cProcName, char * cText1, HB_PTR cText2, char * cText3  )
{
   PHB_ITEM pResult;  
   PHB_ITEM pItem1 = hb_itemPutC( NULL, cText1 );
   PHB_ITEM pItem2 = hb_itemPutPtr( NULL, cText2 );
   PHB_ITEM pItem3 = hb_itemPutC( NULL, cText3 );
   MessageBox( 0, "Point  in hbdllstring5", "1", 0 );
   pResult = hb_itemDoC( cProcName, 3, pItem1, pItem2, pItem3, 0 );
   hb_itemRelease( pItem1 );
   hb_itemRelease( pItem2 );
   hb_itemRelease( pItem3 );
   return hb_itemGetC( pResult );
}
 
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41315
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Creating a LIB or DLL

Postby Antonio Linares » Tue Oct 07, 2014 11:54 pm

Vuelvo a mirarlo y creo que no tiene solución.

Salvo que se me escape algo...
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41315
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Creating a LIB or DLL

Postby asimoes » Thu Oct 09, 2014 1:02 am

Seria uma solução completa além do retorno, a passagem por referência.
A função retornando valor já ajuda muito também.
Isso me queimou muitos neurônios. rs.
Memso assim obrigado pelas dicas.
asimoes
 
Posts: 5
Joined: Mon Sep 29, 2014 10:58 am

Re: Creating a LIB or DLL

Postby asimoes » Thu Oct 09, 2014 2:01 pm

Antonio,

Bom dia!

Ainda não desisti!, observe o código abaixo que funciona a passagem por referência, teria como utilizar técnica com HBDLLSTRING5 ?

Code: Select all  Expand view

hLib := hb_libLoad( "DllMinGw.dll" )
c:="test1"
x:=hb_DynCall( { "test", hLib, HB_DYN_CTYPE_CHAR_PTR } ,@c) //funciona
hb_libFree( hLib )
 

Code: Select all  Expand view

  HB_EXPORT
  char *
  _export
  test(char *a)
  {
     MessageBox( NULL, a, TEXT( HB_I_("Valor de Entrada") ), MB_ICONASTERISK );
     hb_strncpyUpperTrim(a,"teste",sizeof( a ) + 1); //ou hb_strncpy(a,"teste",sizeof( a ) + 1) ou strncpy(a,"teste",sizeof( a ) + 1);
     MessageBox( NULL, a, TEXT( HB_I_("Valor de Saída") ), MB_ICONASTERISK );
     return a;
  }
 
asimoes
 
Posts: 5
Joined: Mon Sep 29, 2014 10:58 am

Previous

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 94 guests