Neues Thema starten

ACCESS VIOLATION beim Zugriff auf worm_transaction_response_transactionNumber

Hallo,

ich verwende Delphi 10.2 und binde die 32-Bit DLL mit stdcall.

Initialisieren und Auslesen der der WormInfo, Login, Logout funktioniert einwandfrei. Auch kann ich eine Transaktion ohne Probleme starten, jeden Falls gibt es keinen Fehlermeldung.

Aber sobald ich auf die worm_transaction_response-Funktionen, wie zB worm_transaction_response_transactionNumber oder logTime zugreif bekomme ich eine ACCESS VIOLATION.

Hier meine Funktionsdefinition:

TWormContex = PIntPtr ; // (^Integer) mit Pointer gibt es das gleiche Problem

TWormUnit = UInt32; (weil 32bit)


function worm_transaction_start (
            context           : TWormContext;
            client_id         : PAnsiChar;
            processData       : PWormData;  // PByte
            processDataLength : TWormUInt;
            processType       : PAnsiChar;
                out response      : TWormResponse
          ) : TWormError; stdcall; external TSE_SWISSBIT_DLL;



function VSwissbit.StartTransaction: Boolean;

var

  client_id         : AnsiString;
  processData       : PWormData;
  processDataLength : TWormUInt;
  processType       : AnsiString;
  transactionNumber : TWormUInt;

begin

    client_id         := AnsiString(config.tse_client_id);

    process_data    := 'Beleg^6.90_0.00_0.00_0.00_0.00^6.90:Bar';
    processData       := PAnsiChar(AnsiString(process_data));
    processDataLength := Length(process_data);
    process_type        := 'KassenBeleg-V1';
    processType       := AnsiString(process_type);


   ppResponse := TWormTransactionResponse.Create(ppContext);


     worm_error  :=  worm_transaction_start(
                      ppContext,
                      PAnsiChar(client_id),
                      processData, processDataLength,
                      PAnsiChar(processType),
                      ppResponse.ptr
                  );


  transactionNumber := ppResponse.TransactionNumber;

 

Result := CheckWormError;

end;



TWormTransactionResponse = class


constructor TWormTransactionResponse.Create(context : TWormContext);
begin
  ptr := worm_transaction_response_new(context); // ptr : PIntPtr;
  if (ptr = Nil) then
    raise Exception.Create('Failed to allocate WormTransactionResponse');
end;

function TWormTransactionResponse.transactionNumber :  TWormUInt;
begin
    Result := worm_transaction_response_transactionNumber(ptr);
end;

...
end;


Hat jemand eine Idee, was ich da falsch mache bzw. worauf ich achten sollte.


Vielen Dank!

Yildiray


Ok, hab den Fehler gefunden.

Ich hatte mich brav an die Doku gehalten und den Parameter für response mit "out" deklariert. Das scheint aber zum Absturz zu führen. Dann musste noch worm_unit UInt64 sein, obwohl ich 32bit verwende.

So sieht nun die Deklaration aus, die nun auch funktioniert:

function worm_transaction_start (
            context           : PWormContext;
            const client_id   : PAnsiChar;
            const processData : PWormData;
            processDataLength : UInt64; // nicht UInt32
            const processType : PAnsiChar;
              response          : PWormResponse // kein out davor!
          ) : TWormError; cdecl; external TSE_SWISSBIT_DLL;

hallo

Ich verwende Delphi Version 7 und frage mich, ob mir jemand bei der Aufzeichnung von Swissbit-Sticks und ähnlichen Funktionen helfen kann.


Anmelden oder Registrieren um einen Kommentar zu veröffentlichen