Reputation: 17
I have a DLL file created in Delphi 7.0 like this:
Function TransInvoices(JSONText : PWideChar) : PChar; stdcall;
var
dm : TdmData;
Begin
dm := TdmData.create(Nil);
Try
Result := dm.Trans(JSONText); // Call Function in DataModule
Finally
FreeAndNil(dm);
End;
End;
exports
TransInvoices;
I called this DLL file in Delphi 10.3 like this:
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons;
Function TransInvoices(JSONText : PWideChar) : PAnsiChar; stdcall; external 'trans.dll';
type
TTransFrom = class(TForm)
TitlePanel: TPanel;
End;
On my development PC and other PCs that have Delphi installed on them, it works good. But a problem happens with PCs that don't have Delphi installed on them. The error message is:
The code execution cannot proceed because borlndmm.dll was not found. Reinstalling the program may fix this problem.
If I don't call the DLL file, and comment it:
// Function TransInvoices(JSONText : PWideChar) : PAnsiChar; stdcall; external 'trans.dll';
Everything works good.
So, where is the problem?
Upvotes: 1
Views: 111
Reputation: 88
I don't know why but it seems that due to the type of parameters you use (PWideChar) the compiler is adding references to the "SharedMem" unit for you (Borlndmm.dll).
You can check the documentation for more information: https://docwiki.embarcadero.com/RADStudio/Athens/en/Sharing_Memory
Upvotes: 0
Reputation: 597906
The code shown is fine, and certainly has no problem with passing strings.
The real "problem" is simply that your DLL has a compile-time dependency on the DLL version of Borland's memory manager. As such, you will have to deploy borlndmm.dll
along with trans.dll
on every PC. If you don't want to do that, you will have to recompile the DLL to remove that dependency.
Upvotes: 3