Histórico da Página
Composition Setup |
---|
import.css=/download/attachments/3279126062824/newLayouttecnologia.css |
|
Pagetitle |
---|
...
Função: ExecInDLLRun
...
|
Executa funções ou procedures de uma DLL (Dynamic-link library , ou Biblioteca de vinculo dinâmica).
Sintaxe
...
ExecInDLLRun ( < nHandle>, < nOpc>, < cBuffer> ) --> Nil
Bloco de código | ||
---|---|---|
| ||
ExecInDllRun( < nHandle >, < nOpc >, < cBuffer > )
|
Parâmetros
...
Nome | Tipo | Descrição | Obrigatório | Referência |
---|---|---|---|---|
nHandle |
...
caractere | Indica o handle da DLL obtida através da função ExecInDLLOpen(). | X |
|
nOpc |
...
numérico | Indica a opção que será executada pela DLL. | X |
|
cBuffer |
...
caractere | Indica o buffer, no formato caracter, que será recebido pela DLL. | X |
...
|
Nil (Nulo)
Observações
- Esta função
...
- retorna
...
- o valor da DLL
...
- com limite de 259 caracteres, para ser passada como referencia. Caso necessite um tamanho maior, utilize a ExeDLLRun2.
- Para o nome da função na DLL, é obrigatorio utilizar ExecInClientDLL, e manter essa assinatura para o correto funcionamento dos parametros.
Exemplos
Bloco de código | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
extern "C" __declspec(dllexport) void ExecInClientDLL(int ID, char * Buf, char * Buf2, int nBuf2)
{
if(ID==1)
{
strcpy(Buf2,"Retorno opção 01");
}
else if (ID == 2)
{
strcpy(Buf2, "Retorno opção 02");
}
}
|
Nota | ||||
---|---|---|---|---|
| ||||
Como pode ser observado, a dll desenvolvida para ser executada com a função ExecinDLLRun tem uma assinatura diferente da utilizada em ExeDLLRun3, por isso não são compativeis e podem causar erros fatais na execução. |
Bloco de código | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
User Function Exemplo()
Local hHdl := 0,buffer := "",xRet1 := 0
// Abre Dll
hHdl //============================================================// DLL DE EXEMPLO EM DELPHI//============================================================library TSTDLL;uses Dialogs;{$R *.RES}function ExecInClientDLL( aFuncID: Integer; aParams: PChar; aBuff: PChar; aBuffSize: Integer ): integer; stdcall;begin if aFuncID=1 then begin // Roda opção 01 showmessage('Executando pela DLL - Texto via parametro: '+chr(13) + aParams); result:=999; end; if aFuncID=2 then begin // Roda opção 02 result:=-1; end;end;exports ExecInClientDLL;beginend.//============================================================// ROTINA EM AdvPL PARA CHAMADA DA DLL//============================================================// Abre DllhHdl := 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 daDLLbuffer DLL buffer:= "Executando a partir da ExecInDllRun..." xRet1 := ExecInDllRun( hHdl, 1, @buffer ) alert("Retorno da ExecInDllRun: " + xRet1) // ExeDllRun2 retorna valor numérico daDLLbuffer 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 DLLbuffer:= "Executando a partir da ExeDllRun3..."nRet3 := ExeDllRun3( hHdl, 1, @buffer ) alert("Retorno da ExeDllRun3: " + StrZero(nRet3,3)) // // ---------------------------------------------------------------- // Fecha aDLLExecInDllClose DLL ExecInDllClose( hHdl ) Return Microsiga Protheus 8.11 , TOTVS Application Server 10 , ByYou Application Server |
Preview
Veja também
Visão Geral
Import HTML Content
Conteúdo das Ferramentas
Tarefas