Como usar dinamicamente uma Dll do Delphi7 no Delphi 8 ???

Delphi

06/10/2004

Estou tentanto utilizar uma Dll feita no Delphi7 a partir do Delphi8 e encontro o seguinte problema ao executar a linha ´Proc´ :

´Object reference not set to an instance of an object´

Obs: De forma estática eu consegui executar... porém preciso que seja dinâmico.

type
   TProc = function : boolean;
var
   MyH  : THandle; // é um inteiro, nao precisa usar o create
   Proc : TProc;
begin
   MyH := LoadLibrary(´Imprime_CAPCA.dll´);
   if MyH <> 0 then
      begin
         @Proc := GetProcAddress (MyH,´Imprime_Ticket_Pesagem´).ToPointer;
         Proc;
      end;
   FreeLibrary(MyH);
end;



E_marcus

E_marcus

Curtidas 0

Respostas

Lbcosta

Lbcosta

06/10/2004

Estou tentanto utilizar uma Dll feita no Delphi7 a partir do Delphi8 e encontro o seguinte problema ao executar a linha ´Proc´ : ´Object reference not set to an instance of an object´ Obs: De forma estática eu consegui executar... porém preciso que seja dinâmico. type TProc = function : boolean; var MyH : THandle; // é um inteiro, nao precisa usar o create Proc : TProc; begin MyH := LoadLibrary(´Imprime_CAPCA.dll´); if MyH 0 then begin @Proc := GetProcAddress (MyH,´Imprime_Ticket_Pesagem´).ToPointer; Proc; end; FreeLibrary(MyH); end;


Tente isso:

type
TImprime_Ticket_Pesagem = function : boolean;
var
MyH : Hwnd;
Imprime_Ticket_Pesagem : TImprime_Ticket_Pesagem;
begin
MyH := LoadLibrary(´Imprime_CAPCA.dll´);
if MyH 0 then
begin
@Imprime_Ticket_Pesagem := GetProcAddress (MyH,´Imprime_Ticket_Pesagem´);
Imprime_Ticket_Pesagem;
end;
FreeLibrary(MyH);
end;


GOSTEI 0
POSTAR