problemas dll activex

01/02/2010

1

Olá,

Instalei uma dll Activex no Delphi e preciso criar outra dll normal (não ActiveX) que acesse as funções desse ActiveX que instalei.

Criei a dll a seguir, mas está dando erro de Access Violation:
library testeZk;
uses
  ShareMem,
  SysUtils,
  Classes,
  Windows,
  ActiveX,
  Graphics,
  OleCtrls,
  OleServer,
  StdVCL,
  Variants,
  ComServ,
  Forms,
  zkemkeeper_TLB in 'zkemkeeper_TLB.pas' {CZKEM: CoClass};

{$R *.res}
{$R *.TLB}

var
  CZKEM1: TCZKEM;

function fnConnect_Net(const IPAdd: WideString; Port: Integer): WordBool;        {$IFDEF WIN32} stdcall; {$ENDIF} {$IFDEF LINUX} cdecl; {$ENDIF}
begin
    result := CZKEM1.Connect_Net(IPAdd, Port);

end;

function fnSetCommPassword(CommKey: Integer): WordBool;        {$IFDEF WIN32} stdcall; {$ENDIF} {$IFDEF LINUX} cdecl; {$ENDIF}
begin
    result := CZKEM1.SetCommPassword(CommKey);
end;

exports fnConnect_Net;
exports fnSetCommPassword;
exports DllGetClassObject, DllCanUnloadNow, DllRegisterServer, DllUnregisterServer;
end.

Quando testo a função fnConnect_Net da dll acima, dá o seguinte erro:
Project Project2.exe raised exception class EAccessViolation with message 'Access violation at address 00386B16 in module testeZk.dll'. Read of address 0000022F0'. Process stopped. Use Step or Run to continue.

Alguém tem alguma sugestão? O que estou fazendo errado?
Obs.: Fiz baseado no exemplo desse link: http://pw1.netcom.com/~cherrman/dl030.htm.

Grato,
Sidarta.
Responder