Árvore de páginas

Versões comparadas

Chave

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

...

Bloco de código
languagecpp
themeEclipse
linenumberstrue
collapsefalse
extern "C" __declspec(dllexport) int ExecInClientDLL(int idCommand, char * buffParam, int buffParamLen, char * buffOutput, int * buffOutputLen)
{
	switch (idCommand)
	{
	case COMMAND1:
	{
		strcpy(buffOutput, "Comando 100");
		*buffOutputLen = strlen(buffOutput);
		return RETURN_COMMAND1;
	}
	case COMMAND2:
	{
		strcpy(buffOutput, "Comando 2000");
		*buffOutputLen = strlen(buffOutput);
		return RETURN_COMMAND2;
	}

	default:
		*buffOutputLen = 0;
		strcpy(buffOutput, "Comando inválido");
		*buffOutputLen = strlen(buffOutput);
		return 0;
	}
}
Nota
icontrue
titleAtenção

Como pode ser observado, a dll desenvolvida para ser executada com a função ExeDLLRun3 tem uma assinatura diferente da utilizada em ExeDLLRun2 e ExeinDLLRun, por isso não são compatíveis e podem causar erros fatais na execução.

Bloco de código
languagecpp
themeEclipse
linenumberstrue
collapsefalse
#define MB_OK                       0
#define MB_OKCANCEL                 1
#define MB_YESNO                    4
#define MB_ICONHAND                 16
#define MB_ICONQUESTION             32
#define MB_ICONEXCLAMATION          48
#define MB_ICONASTERISK             64

User Function DllTeste()
 
Local hHdl := 0,buffer := "",xRet1 := 0
// Abre Dll
hHdl := ExecInDLLOpen( "DllTeste.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 ExecInDllRun2..."
xRet1 := ExeDllRun3( hHdl, 1, @buffer )
MessageBox("Retorno da ExeDllRun3: " + Alltrim(Str(xRet1)) + " - " + buffer, "ExeDllRun2ExeDllRun3", MB_ICONEXCLAMATION)
  
// ExeDllRun3 retorna valor numérico da DLL
buffer:= "Executando a partir da ExeDllRun3..."
xRet2 := ExeDllRun3( hHdl, 2, @buffer )
MessageBox("Retorno da ExeDllRun3: " + Alltrim(Str(xRet2)) + " - " + buffer, "ExeDllRun2ExeDllRun3", MB_ICONEXCLAMATION)

// ExeDllRun3 retorna valor numérico da DLL
buffer:= "Executando a partir da ExeDllRun3..."
xRet3 := ExeDllRun3( hHdl, 3, @buffer )
MessageBox("Retorno da ExeDllRun3: " + Alltrim(Str(xRet3)) + " - " + buffer, "ExeDllRun2ExeDllRun3", MB_ICONEXCLAMATION)

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

Preview


Image RemovedImage Added


Veja também

...