Fórum Leitura de DLL #384611
25/08/2010
0
Olá pessoal estou tentando fazer a leitura de uma dll explicita porém ao tentar ler a dll ocorre o sequinte erro:
Access violation at address 00406064 in module 'UsaDll.exe'. Read of address 0115916C.
Código da função na DLL:
function DataHora(vOperacao: Integer): string; export;
begin
case vOperacao of
1: Result := DateToStr(Date);
2: Result := TimeToStr(Time);
end;
end;
exports
DataHora;
Chamada da função na aplicação:
type
TFuncao = function (vOperacao: Integer): string;
procedure TForm1.btn_DataClick(Sender: TObject);
var func: TFuncao;
dll: THandle;
begin
try
dll := LoadLibrary('ExemploDll');
func := GetProcAddress(dll, 'DataHora');
lbResult.Caption := func(1);
finally
FreeLibrary(dll);
end;
end;
Access violation at address 00406064 in module 'UsaDll.exe'. Read of address 0115916C.
Código da função na DLL:
function DataHora(vOperacao: Integer): string; export;
begin
case vOperacao of
1: Result := DateToStr(Date);
2: Result := TimeToStr(Time);
end;
end;
exports
DataHora;
Chamada da função na aplicação:
type
TFuncao = function (vOperacao: Integer): string;
procedure TForm1.btn_DataClick(Sender: TObject);
var func: TFuncao;
dll: THandle;
begin
try
dll := LoadLibrary('ExemploDll');
func := GetProcAddress(dll, 'DataHora');
lbResult.Caption := func(1);
finally
FreeLibrary(dll);
end;
end;
Alberto Filho..
Curtir tópico
+ 0
Responder
Clique aqui para fazer login e interagir na Comunidade :)