Árvore de páginas

Versões comparadas

Chave

  • Esta linha foi adicionada.
  • Esta linha foi removida.
  • A formatação mudou.

...

Portuguese

Pagetitle
ExeDLLRun2
ExeDLLRun2

Função: ExeDLLRun2

Executa functions ou procedures de uma determinada DLL - Dynamic-link library (Biblioteca de ligação dinâmica).

ExeDLLRun2 ( < nHandle>, < nOpc>, < cBuffer> ) --> nRet

 

NomeTipoDescriçãoObrigatórioReferência
nHandleNuméricoIndica o handle da DLL obtida através da função ExecInDLLOpen().X 
nOpcNuméricoIndica a opção que será executada pela DLL.X 
cBufferCaracterIndica o buffer, no formato caracter, que será recebido pela DLL.X 

 

nRet
    (numerico)
  • Retorno vindo da DLL após o processamento.
A variável cBuffer tem limite de 20000 caracteres, para ser passada como referencia.

 

Bloco de código
themeEclipse
languagedelphi
titleDLL DE EXEMPLO EM DELPHI
linenumberstrue
library TSTDLL;
uses  Dialogs;
//============================================================
// DLL DE EXEMPLO EM DELPHI
//============================================================
library TSTDLL;
uses  Dialogs;
{$R *.RES}



function ExecInClientDLL( aFuncID: Integer;
                         
 aParams: PChar;                         
 aBuff: PChar;                         
 aBuffSize
                          
 aParams: PChar;                          
 aBuff: PChar;                          
 aBuffSize: Integer ): integer; stdcall;

begin 
 if

begin  
 if aFuncID=1 
then  begin    
  
then  begin     
  // Roda opção 
01    
  showmessage
01     
  showmessage('Executando pela DLL - Texto via parametro: '+chr(13) + aParams);
    
  result
     
  result:=999;
 
 end; 
 if
  
 end;  

 if aFuncID=2 then 
begin    
  
begin     
  // Roda opção
02    
  result
 02     
  result:=-1;
 
 end;
end;
  
 end;
end;

exports ExecInClientDLL;


begin


end.

//============================================================
// ROTINA EM AdvPL PARA CHAMADA DA DLL
//============================================================

 

Bloco de código
themeEclipse
languagecpp
titleROTINA EM AdvPL PARA CHAMADA DA DLL
linenumberstrue
// Abre Dll


hHdl := ExecInDLLOpen( "TSTDLL.DLL" )
 
 

// ----------------------------------------------------------------


// Envia comando para execução, repare que estamos 


// usando a opção "1" no momento de chamar a DLL.


// ----------------------------------------------------------------



// ExecInDllRun não retorna valor da DLL


buffer:= "Executando a partir da ExecInDllRun..."


xRet1 := ExecInDllRun( hHdl, 1, @buffer )
 
  


alert("Retorno da ExecInDllRun: " + xRet1)



// ExeDllRun2 retorna valor numérico da DLL


buffer:= "Executando a partir da ExeDllRun2..."


nRet2 := ExeDllRun2( hHdl, 1, @buffer ) 


alert("Retorno da ExeDllRun2: " + StrZero(nRet2,3))
      
       

// ExeDllRun3 retorna valor numérico da DLL


buffer:= "Executando a partir da ExeDllRun3..."


nRet3 := ExeDllRun3( hHdl, 1, @buffer ) 


alert("Retorno da ExeDllRun3: " + StrZero(nRet3,3))
      
       

// ----------------------------------------------------------------


// Fecha a DLL


ExecInDllClose( hHdl )

 

Microsiga Protheus 8.11 , TOTVS Application Server 10 , ByYou Application Server

 

...