Autor Beitrag
Peter18
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 489
Erhaltene Danke: 2


Delphi4
BeitragVerfasst: Do 08.01.15 14:19 
Ein freundliches Hallo an alle,

mit der Speicherverwaltung bei Pascal tue ich mich noch etwas schwer, so hoffe ich jemand kann mir einen Tipp geben, was hier falsch ist.

Ich habe ein kleines Testprogramm geschrieben, mit dem ich mich bei der CAPI ein wenig umsehen möchte. "CAPI_REGISTER" funktioniert auch. Wenn ich aber "CAPI_PUT_MESSAGE( AppID, ConRq );" verwende, erhalte ich die Fehlermeldung "Zugriffsverletzung bei der Capi32.dll". Die Variable ConRq ist so deklariert:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
Type Connect_Req = Record
    Length            : Integer;
    Command           : Byte    ;
    Subcommand        : Byte    ;
    Controller        : Longword;
    CIP               : Word    ;
    CalledNumberTyp   : Byte    ;
    CalledNumber      : PChar   ;
    CallingNumberTyp  : Byte    ;
    CallingNumberTyp1 : Byte    ;
    CallingNumber     : PChar   ;
    CalledSubTyp      : Byte    ;
    CalledSub         : PChar   ;
    CallingSubTyp     : Byte    ;
    CallingSub        : Byte    ;
    BProt             : Word    ;
    BC                : Byte    ;
    LLC               : Byte    ;
    HLC               : Byte    ;
    AdditionalInfo    : Byte    ;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  ConRq  : Connect_Req;

Die Funktion "CAPI_PUT_MESSAGE" verlangt den Typ "Connect_Req" aber keinen Pointer.

Ich hoffe jemand hat einen Tipp, wie die Struktur korrekt aufbauen kann.

Grüße von der Nordsee

Peter
baumina
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 305
Erhaltene Danke: 61

Win 7
Delphi 10.2 Tokyo Enterprise
BeitragVerfasst: Do 08.01.15 14:56 
user profile iconPeter18 hat folgendes geschrieben Zum zitierten Posting springen:
Die Funktion "CAPI_PUT_MESSAGE" verlangt den Typ "Connect_Req" aber keinen Pointer.


Ich denke Connect_Req müsste ein Pointer sein, aber ohne Quellcode weiß man nix genaues.
Peter18 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 489
Erhaltene Danke: 2


Delphi4
BeitragVerfasst: Do 08.01.15 16:18 
Hallo baumina,

danke für Deine Antwort. Wenn ich einen Pointer übergebe erhalte ich eine Fehlermeldung. Die Programmierhilfe sagt: "D_AppID: Integer; pcapimessage: Connect_Req".

Der Quelltext beinhaltet sonst nur Eintragen der Daten und den Aufruf "Res := CAPI_PUT_MESSAGE( AppID, ConRq );". Wenn Du den Fehler in den Daten der Struktur vermutest kann ich die natürlich auch noch liefern.

Grüße von der Nordsee

Peter
baumina
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 305
Erhaltene Danke: 61

Win 7
Delphi 10.2 Tokyo Enterprise
BeitragVerfasst: Do 08.01.15 16:29 
Ich meinte den Quelltext von CAPI_PUT_MESSAGE der muss ja in irgendeiner Unit drin stehen.
Peter18 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 489
Erhaltene Danke: 2


Delphi4
BeitragVerfasst: Do 08.01.15 17:00 
Hallo baumina,

nochmals danke für Deine Antwort. Man sollte seine Saftware vollständig lesen, wenn man sie nach längerer Zeit wieder aufwärmt.

Weil die importierte Schnittstelle nicht zur CAPI-Beschreibung (AVM) passt hatte ich die Schnittstelle manuell deklariert und dabei den Parameter nicht als Zeiger eingetragen. Mit
ausblenden Delphi-Quelltext
1:
2:
3:
  Function  CAPI_PUT_MESSAGE    (     D_AppID                : Longint;
                                      pcapimessage           : P_Conn_Req ): Longint; stdcallexternal
                                                                                              'Capi2032.dll';

ist der Fehler behoben.

Grüße von der Nordsee

Peter
Gerd Kayser
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 632
Erhaltene Danke: 121

Win 7 32-bit
Delphi 2006/XE
BeitragVerfasst: Fr 09.01.15 05:32 
user profile iconPeter18 hat folgendes geschrieben Zum zitierten Posting springen:

ausblenden Delphi-Quelltext
1:
Type Connect_Req = Record					

Müsste es nicht so heißen:
ausblenden Delphi-Quelltext
1:
Type Connect_Req = packed Record					
Peter18 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 489
Erhaltene Danke: 2


Delphi4
BeitragVerfasst: Mo 19.01.15 17:37 
Hallo Gerd Kayser,

danke für die Antwort. Ob "Record" oder "packed Record" macht in diesem Fall anscheinend keinen Unterschied, beides scheint zu funktionieren.

Grüße von der Nordsee

Peter