I have the following DLL procedure:
procedure OPENDB(IBTrans: TIBTransaction; IBQuery: TIBQuery;
SQL: String); stdcall;
begin
if IBQuery.Active = True then IBQuery.Active := False;
if IBTrans.Active = True then IBTrans.Active := False;
IBQuery.SQL.Clear;
IBQuery.SQL.Add(SQL);
IBTrans.Active := true;
IBQuery.Active := True;
end;
In my program I call the ddl that is in the \'winnt\\system32\'
folder as follows:
procedure OPENDB(IBTrans: TIBTransaction; IBQuery: TIBQuery;
SQL: String); stdcall; external \'saudedll.dll\';
when i'm going to use the procedure to open the database i see an error. I only happens with procedures that use interbase components. If I declare the procedure in my own executable, it doesn't make any kind of mistake, it works perfectly. Can someone give me a hint? Thank you in advance!!
UPDATE -----------------
library Biblio;
{ Important note about DLL memory management: ShareMem must be the
first unit in your library's USES Project-View Source) USES clause if your DLL exports procedures or functions that pass strings as parameters or function results. This to all strings passed to and from your DLL—even those are nested in records and classes. ShareMem is the interface unit to the BORLNDMM.DLL shared memory manager, which must be deployed
with your DLL. To avoid using BORLNDMM.DLL, pass string
using PChar or ShortString parameters. }
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, Grids, DBGrids, Buttons, StdCtrls, Mask, DBCtrls, ExtCtrls,
ActnList, ComCtrls, FMTBcd, Provider, DBClient;
{$R *.res}
procedure LimpaCampos(vForm: TForm; vFormHandle: THandle);
var i : Integer;
begin
for i := 0 to (vForm.ControlCount -1) do
if vForm.Controls[i].ClassName = ´TEdit´ then
begin
TEdit(vForm.Controls[i]).Text:=´´;
end;
for i := 0 to (vForm.ControlCount -1) do
if vForm.Controls[i].ClassName = ´TDBEdit´ then
begin
TDBEdit(vForm.Controls[i]).Text:=´´;
end;
for i := 0 to (vForm.ControlCount -1) do
if vForm.Controls[i].ClassName = ´TCheckBox´ then
begin
TCheckBox(vForm.Controls[i]).Checked:= False;
end;
for i := 0 to (vForm.ControlCount -1) do
if vForm.Controls[i].ClassName = ´TDBCheckBox´ then
begin
TDBCheckBox(vForm.Controls[i]).Checked:= False;
end;
Exports
LimpaCampos;
begin
end.
And in the Form frmCadKits I declare the procedure and the dll.
...
public
{ Public declarations }
end;
procedure LimpaCampos(vForm: TForm; vFormHandle: THandle); external ´biblio.dll´;
var
...
And I make a call in the Form show
procedure TfrmCadKits.FormShow(Sender: TObject);
begin
LimpaCampos(frmCadKits,frmCadKits.Handle);
end;
And I get the error:
Project Application.exe raised class EAccessViolation with message 'Access violation