Use register...

No help do Delphi há uma explicação completa sobre isso. Mas para dizer que
eu não ajudei...

"Isto" existe para informar ao compilador/linkeditor de que forma ele deve
passar os parametros de funcao para a dll.

com register, ele tenta passar os parâmetros (até 3) usando os registradores
do processador. É o padrão do Delphi. É o único parâmetro que usa
registradores e é recomendável, caso você não vá usar esta dll com outra
linguagem.

pascal, se não me falha a memória, era o método usado pela Borland nos
antigos compiladores, stdcall é usado quando você vai usar sua dll com
outras linguagens, cdecl, para compatibilidade com C e C++. As diferenças
basicamente são a ordem de envio dos parâmetros e se a limpeza da pilha vai
ser feita por que chamou a dll ou pela própria dll.

safecall é um mistério para mim. Há que se pesquisar na Bíblia do Cantu...
Algo a ver com COM, conforme help.

Alexandre Pedroto

E, a ajudinha do help do Delphi. ;-)

When you declare a procedure or function, you can specify a calling
convention using one of the directives register, pascal, cdecl, stdcall, and
safecall. For example,

function MyFunction(X, Y: Real): Real; cdecl;
 ...

Calling conventions determine the order in which parameters are passed to
the routine. They also affect the removal of parameters from the stack, the
use of registers for passing parameters, and error and exception handling.
The default calling convention is register.

The register and pascal conventions pass parameters from left to right; that
is, the left most parameter is evaluated and passed first and the rightmost
parameter is evaluated and passed last. The cdecl, stdcall, and safecall
conventions pass parameters from right to left.
        For all conventions except cdecl, the procedure or function removes
parameters from the stack upon returning. With the cdecl convention, the
caller removes parameters from the stack when the call returns.

The register convention uses up to three CPU registers to pass parameters,
while the other conventions pass all parameters on the stack.
        The safecall convention implements exception "firewalls." On Windows, this
implements interprocess COM error notification.

The table below summarizes calling conventions.

Calling conventions
Directive       Parameter order Clean-up        Passes parameters in registers?
register        Left-to-right   Routine Yes
pascal  Left-to-right   Routine No
cdecl   Right-to-left   Caller  No
stdcall Right-to-left   Routine No
safecall        Right-to-left   Routine No
The default register convention is the most efficient, since it usually
avoids creation of a stack frame. (Access methods for published properties
must use register.) The cdecl convention is useful when you call functions
from shared libraries written in C or C++, while stdcall and safecall are
recommended, in general, for calls to external code. On Windows, the
operating system APIs are stdcall and safecall. Other operating systems
generally use cdecl. (Note that stdcall is more efficient than cdecl.)

The safecall convention must be used for declaring dual-interface methods.
The pascal convention is maintained for backward compatibility. For more
information on calling conventions, see Program control.
The directives near, far, and export refer to calling conventions in 16-bit
Windows programming. They have no effect in 32-bit applications and are
maintained for backward compatibility only.

> >-----Mensagem original-----
> >De: Rafael Stoever [mailto:[EMAIL PROTECTED]
> >Enviada em: quarta-feira, 13 de outubro de 2004 14:30
> >Para: [EMAIL PROTECTED]
> >Assunto: [delphi-br] register; pascal; cdecl; stdcall; safecall
> >
> >
> >
> >Alguém poderia me explicar com uma linguagem mais simples ou com
> >um exemplo de como e p/ que é q existe isto ???
> >
> >register; pascal; cdecl; stdcall; safecall
> >
> >
> >
> >estou usando agora o cdecl e stdcall ..
> >
> >
> >
> >Atenciosamente.
> >
> >.Rafael Stoever .Desenvolvimento
> >
> >
> >[As partes desta mensagem que não continham texto foram removidas]
> >
> >
> >
> >--
> ><<<<< FAVOR REMOVER ESTA PARTE AO RESPONDER ESTA MENSAGEM >>>>>
> >
> >Para ver as mensagens antigas, acesse:
> > http://br.groups.yahoo.com/group/delphi-br/messages
> >
> >Para falar com o moderador, envie um e-mail para:
> > [EMAIL PROTECTED] ou [EMAIL PROTECTED]
> >
> >Links do Yahoo! Grupos
> >
> >
> >
> >
> >
> >
> >
> >
> >---
> >Email sem vírus
> >Checked by AVG anti-virus system (http://www.grisoft.com).
> >Version: 6.0.776 / Virus Database: 523 - Release Date: 12/10/2004
> >
---
Email sem vírus
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.776 / Virus Database: 523 - Release Date: 12/10/2004



-- 
<<<<< FAVOR REMOVER ESTA PARTE AO RESPONDER ESTA MENSAGEM >>>>>

Para ver as mensagens antigas, acesse:
 http://br.groups.yahoo.com/group/delphi-br/messages

Para falar com o moderador, envie um e-mail para:
 [EMAIL PROTECTED] ou [EMAIL PROTECTED]
 
Links do Yahoo! Grupos

<*> Para visitar o site do seu grupo na web, acesse:
    http://br.groups.yahoo.com/group/delphi-br/

<*> Para sair deste grupo, envie um e-mail para:
    [EMAIL PROTECTED]

<*> O uso que você faz do Yahoo! Grupos está sujeito aos:
    http://br.yahoo.com/info/utos.html

 



Responder a