Declarar função DLL - SOLUCIONADO

Declarar função DLL - SOLUCIONADO

Postby MGA » Tue Mar 08, 2016 6:21 pm

ConsultarStatusOperacional = (char* (_cdecl* )(int numeroSessao, char* codigoDeAtivacao))

Estou declarando a função como abaixo e esta dando erro no xharbour:

DLL32 FUNCTION ConsultarStatusOperacional( numeroSessao AS _INT, codigoAtivacao AS STRING ) AS STRING PASCAL LIB s_nDllHandle

alguem sabe o que pode estar acontecendo?


private: System::Void btnConsultaStatusOperacional_Click(System::Object^ sender, System::EventArgs^ e) {
//Inicia a dll e declara a função ConsultarStatusOperacional
LPCSTR x = (LPCSTR)"GerSAT.dll";
HINSTANCE HGerSat = LoadLibraryA (x);
if (HGerSat != NULL){
ConsultarStatusOperacional = (char* (_cdecl* )(int numeroSessao, char* codigoDeAtivacao))
GetProcAddress (HGerSat, "ConsultarStatusOperacional");
int numeroSessao = NumeroRand();
// Efetua a consulta do status do GerSAT
String^ resposta = gcnew System::String(ConsultarStatusOperacional(numeroSessao, StringToChar(txtCodigoDeAtivacao->Text)));

MessageBox::Show(resposta->Replace('|', '\n'), "Consulta Status Operacional");
};
FreeLibrary(HGerSat);
}
Last edited by MGA on Tue Mar 08, 2016 7:36 pm, edited 2 times in total.
ubiratanmga@gmail.com

FWH24.04
BCC7.3
HARBOUR3.2
xMate
Pelles´C
TDolphin
MGA
 
Posts: 1252
Joined: Mon Feb 25, 2008 2:54 pm
Location: Brasil/PR/Maringá

Re: Declarar função DLL

Postby MGA » Tue Mar 08, 2016 7:35 pm

resolvido! :)

#pragma BEGINDUMP

#include <windows.h>
#include "hbapi.h"
#include "hbapierr.h"

static HINSTANCE handleLeitura;

HB_FUNC(LOADDLLFISCNET){
handleLeitura = LoadLibrary( "GERSAT.dll" );
}

HB_FUNC(FREEDLLFISCNET){
FreeLibrary( handleLeitura );
}

typedef char* ( __cdecl * PTRConsultarStatusOperacional ) ( int numeroSessao, char * codigoDeAtivacao );


HB_FUNC( CONSULTARSTATUSOPERACIONAL )
{

if( ISCHAR( 1 ) && ISCHAR( 2 ) )
{
PTRConsultarStatusOperacional pFunc;
pFunc = (PTRConsultarStatusOperacional) GetProcAddress( handleLeitura, "ConsultarStatusOperacional" );

if ( pFunc )
hb_retc( pFunc( hb_parni( 1 ), hb_parc( 2 ) ) );
else
hb_errRT_BASE_SubstR( EG_NOFUNC, 9999, NULL, "ConsultarStatusOperacional", HB_ERR_ARGS_BASEPARAMS );
}
else
hb_errRT_BASE_SubstR( EG_ARG, 9999, NULL, "ConsultarStatusOperacional", HB_ERR_ARGS_BASEPARAMS );

// hb_retc( "" );
}

#pragma ENDDUMP
ubiratanmga@gmail.com

FWH24.04
BCC7.3
HARBOUR3.2
xMate
Pelles´C
TDolphin
MGA
 
Posts: 1252
Joined: Mon Feb 25, 2008 2:54 pm
Location: Brasil/PR/Maringá

Re: Declarar função DLL - SOLUCIONADO

Postby MGA » Wed Mar 09, 2016 12:44 pm

nPonteiro := DLLCall(s_nDllHandle, 32, "AtivarSAT", nNumeroSessao, nSubComando, cCodigoDeAtivacao, cCNPJ, nUF )
cRetorno := SAT_RetornaCodificacaoCorreta( HB_Pointer2String( nPonteiro, RetornaTamanhoBuffer( nPonteiro ) ) )


#pragma BEGINDUMP

#include <windows.h>
#include "hbapi.h"
#include "hbapierr.h"

HB_FUNC( RETORNATAMANHOBUFFER )
{

hb_retni( strlen( (const char *) hb_parni(1) ) );

}


#pragma ENDDUMP
ubiratanmga@gmail.com

FWH24.04
BCC7.3
HARBOUR3.2
xMate
Pelles´C
TDolphin
MGA
 
Posts: 1252
Joined: Mon Feb 25, 2008 2:54 pm
Location: Brasil/PR/Maringá


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 87 guests