Forum > FPC development

application could not be started correctly (0xc000007)

<< < (3/3)

PascalDragon:

--- Quote from: Weitentaaal on October 28, 2020, 01:54:08 pm ---
--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---unit Unit1; {$mode objfpc}{$H+} interface uses  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls,  sqldb,  SQLite3Conn, DB; type   { TForm1 }   TForm1 = class(TForm)    Button1: TButton;    procedure Button1Click(Sender: TObject);  private   public   end; var  Form1: TForm1;   Procedure dbExecute(var Recordset: TSQLQuery; Query: String); external 'networkdb.dll';  Procedure initNetworkDB(MacAdresse, pathToWGR: String; ZeichnungsNr: Integer; DATABASE_MODE: Integer = 2);external 'networkdb.dll'; implementation {$R *.lfm} { TForm1 } procedure TForm1.Button1Click(Sender: TObject);var  dbT: TSQLQuery;begin  ShowMessage('Before dll');  initNetworkDB('rand','C:\WGKBlck\Data\', 1, 2);  ShowMessage('t1');  dbT := TSQLQuery.Create(nil);  showMessage('t2');  showMessage('t3');  dbExecute(dbT ,'SELECT * FROM Plattentauscher');  ShowMessage('t4');   ShowMessage(dbT.FieldByName('INDEX').Text);   dbT.Free;end;end. 
--- End quote ---

Do not pass class instances as such across binary boundaries. This is an accident waiting to happen.

You need to handle this with opaque types (and rvk is right about strings as well, though those could be solved with a shared memory manager). For example:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---type  TDllQuery = Pointer;  TDllField = Pointer;   Procedure dbExecute(Recordset: TDllQuery; Query: String); external 'networkdb.dll';  Procedure initNetworkDB(MacAdresse, pathToWGR: PChar; ZeichnungsNr: Integer; DATABASE_MODE: Integer = 2);external 'networkdb.dll';  function CreateQuery: TDllQuery; external 'networkdb.dll';  procedure FreeQuery(aQuery: TDllQuery); external 'networkdb.dll';  function QueryFieldByName(aQuery: TDllQuery; aField: PChar): TDllField; external 'networkdb.dll';  function FieldText(aField: TDllField): PChar; exteranl 'networkdb.dll'; 
In your library  you can simply return the class instance of the TSQLQuery or the TField, but you must not access it as such outside of your library.

Essentially you need to flatten your API if you want to use it like that.

Such problems will only be solved once the compiler and RTL fully support dynamic packages.

Weitentaaal:
Thank u :) I know what my mistakes are now :)

Navigation

[0] Message Index

[*] Previous page

Go to full version