Árvore de páginas

Versões comparadas

Chave

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

...

Portuguese

Pagetitle
ExecInDLLOpen
ExecInDLLOpen

Função: ExecInDLLOpen

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

ExecInDLLOpen ( < cDLLName> ) --> nHandle

 

NomeTipoDescriçãoObrigatórioReferência
cDLLNameCaracterIndica o nome do arquivo da DLL.X 

 

nHandle
    (numerico)
  • Retorna o handle de abertura da DLL.

A DLL que será manipulada deve estar no mesmo diretório do Smart Client.

//============================================================// DLL DE EXEMPLO EM DELPHI//============================================================library TSTDLL;uses Dialogs;

 

Bloco de código
themeEclipse
languagedelphi
titleDLL de exemplo em Delphi
linenumberstrue
library DLLProtheus;
uses sysutils;
{$R *.RES}

function ExecInClientDLL( 
aFuncID
ID: Integer; 
aParams
aPar: PChar; 
aBuff
Buf: PChar; 
aBuffSize
nBuf: Integer ): integer; stdcall;
begin
  
if
  result 
aFuncID
:= -1;


 
then
  
begin
 if (ID = 1) 
//
then 
Roda
begin
 
opção
 
01
    StrPCopy(Buf, 
showmessage
PChar('
Executando
Retorno 
pela DLL - Texto via parametro: '+chr(13) + aParams);
opção 01'));
      result :=
999
 200;
    end
;
 else if 
aFuncID
(ID = 2
)then begin
     
// Roda
 StrPCopy(Buf, PChar('Retorno opção 02'));
      result :=
-1
 300;
    end;


end;


exports ExecInClientDLL;
beginend.//============================================================// ROTINA EM AdvPL PARA CHAMADA DA DLL//============================================================// Abre DllhHdl

begin
end.
Bloco de código
themeEclipse
languagecpp
titleRotina de exemplo em AdvPL
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 
DLLbuffer
DLL
buffer:= "Executando a partir da ExecInDllRun..."
xRet1 := ExecInDllRun( hHdl, 1, @buffer )

alert("Retorno da ExecInDllRun: " + xRet1)


// ExeDllRun2 retorna valor numérico da 
DLLbuffer
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
DLL
buffer:= "Executando a partir da ExeDllRun3..."
nRet3 := ExeDllRun3( hHdl, 1, @buffer )

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


// ----------------------------------------------------------------
// Fecha a 
DLLExecInDllClose
DLL
ExecInDllClose( hHdl )


 

Exemplo da função ExecInDLLOpen()
Microsiga Protheus 8.11 , TOTVS Application Server 10 , ByYou Application Server