Fórum Dll´s #213119
11/02/2004
0
Bom. Criei uma DLL simples veja o FONTE:
library AtestadoFun;
{ Important note about DLL memory management: ShareMem must be the
first unit in your library´s USES clause AND your project´s (select
Project-View Source) USES clause if your DLL exports any procedures or
functions that pass strings as parameters or function results. This
applies to all strings passed to and from your DLL--even those that
are nested in records and classes. ShareMem is the interface unit to
the BORLNDMM.DLL shared memory manager, which must be deployed along
with your DLL. To avoid using BORLNDMM.DLL, pass string information
using PChar or ShortString parameters. }
uses
SysUtils,
Classes;
{$R *.RES}
function TestaCnpj(xCNPJ: String):Boolean;
Var
d1,d4,xx,nCount,fator,resto,digito1,digito2 : Integer;
Check: String;
begin
d1 := 0;
d4 := 0;
xx := 1;
for nCount := 1 to Length( xCNPJ )-2 do
begin
if Pos( Copy( xCNPJ, nCount, 1 ), ´/-.´ ) = 0 then
begin
if xx < 5 then
begin
fator := 6 - xx;
end
else
begin
fator := 14 - xx;
end;
d1 := d1 + StrToInt( Copy( xCNPJ, nCount, 1 ) ) * fator;
if xx < 6 then
begin
fator := 7 - xx;
end
else
begin
fator := 15 - xx; end;
d4 := d4 + StrToInt( Copy( xCNPJ, nCount, 1 ) ) * fator;
xx := xx+1;
end;
end;
resto := (d1 mod 11);
if resto < 2 then
begin
digito1 := 0;
end
else
begin
digito1 := 11 - resto;
end;
d4 := d4 + 2 * digito1;
resto := (d4 mod 11);
if resto < 2 then
begin
digito2 := 0;
end
else
begin
digito2 := 11 - resto;
end;
Check := IntToStr(Digito1) + IntToStr(Digito2);
if Check <> copy(xCNPJ,succ(length(xCNPJ)-2),2) then
begin
Result := False;
end
else
begin
Result := True;
end;
end;
function TestaQtdCnpj(xCNPJ: String):Boolean;
var
Aux :String[13];
x:integer;
begin
aux[0]:=xCNPJ[1];
aux[1]:=xCNPJ[2];
aux[2]:=xCNPJ[4];
aux[3]:=xCNPJ[5];
aux[4]:=xCNPJ[6];
aux[5]:=xCNPJ[8];
aux[6]:=xCNPJ[9];
aux[7]:=xCNPJ[10];
aux[8]:=xCNPJ[12];
aux[9]:=xCNPJ[13];
aux[10]:=xCNPJ[14];
aux[11]:=xCNPJ[15];
aux[12]:=xCNPJ[17];
aux[13]:=xCNPJ[18];
for x:=0 to 13 do
begin
if (aux[x]in[´ ´])then
begin
Result := False;
end
else
Result := True;
end;
end;
exports
TestaCnpj index 1;
exports
TestaQtdCnpj index 2;
begin
end.
Pois bem. Eu declaro assim:
.
.
.
function TestaCnpj(xCNPJ: String):Boolean;stdcall
external ´AtestadoFun.DLL´ index 1;
function TestaQtdCnpj(xCNPJ: String):Boolean;stdcall
external ´AtestadoFun.DLL´ index 2;
var
FClientesNovo: TFClientesNovo;
implementation
So que o Problema e que quando uso a função o programa da um erro e tenho que fechar
O que pode ser?
Valeu a Paciensia...
Dart
Dart
Curtir tópico
+ 0Posts
11/02/2004
Marcelo
var
...
function SuaFuncao( Variaveis: Tipo ):Retorno; external ´SuaDll.dll´
Valeu?
Obs. : Quando for digitar o nome da funcao e o da dll com caminho ou nao, os caracters devem estar da mesma forma que na dll, ou seja, maiuscoula e minuscula. Qualquer duvida eh so entrar em contato comigo!
Gostei + 0
11/02/2004
Caninha51
Gostei + 0
11/02/2004
Vanius
Em meus sistemas, utilizo a declaraçoes de funcoes (no caso de DLL´s) depois da palavra
implementation
...//coloco aqui
Abraços,
Vanius
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)