0

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
ldnamdd
  • 37
  • 5
  • 2
    "i see an error" We don't. – Olivier Jun 21 '20 at 19:59
  • I'm surprised that you're surprised that there are problems trying to use Delphi classes that are in a .DLL. See https://stackoverflow.com/questions/12954973/putting-classes-in-a-dll. The only way you'll get this to work is if your .DLL is actually a Delphi package. – MartynA Jun 21 '20 at 20:24
  • http://www.rvelthuis.de/articles/articles-dlls.html – Delphi Coder Jun 21 '20 at 22:25
  • 1
    *I see an error* isn't a problem description unless you tell us what that error is - we can't see your screen from here, so we don't know what you're seeing. The message is on the screen right in front of you, so there's no reason for you to not include that information here so we can see it too. Please [edit] your post to provide the **exact** error message you're getting. – Ken White Jun 22 '20 at 02:25
  • I see, you are right. I have updated the problem I am having. I think now is better describled. – ldnamdd Jun 22 '20 at 18:46

0 Answers0