Autor Beitrag
hathor
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Sa 08.09.07 16:05 
C++:
char *version;
int cpu0core0t;
...
version = "1.00";
cpu0core0t = 10; //dummy wert
etc.

wird ins Shared Memory geschrieben:

auslesen mit einem C++-Programm geht problemlos.

Mit einem Delphi-Programm kann ich nur Integer-Werte auslesen,
bei den Strings kommt nur Müll heraus.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
type
  TSharedData =  record
    cpu0core0t : Integer; //coretemp von cpu0,core0
  version: array [0..3] of char; 
  ...
...

  with SharedData^ do
    Begin
      Memo1.lines.add(Inttostr(cpu0core0t));   //geht
    Memo1.lines.add(version);     //geht nicht
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Sa 08.09.07 17:12 
char * ist (wie's der Typ eindeutig sagt) ein Zeiger auf einen char. So muss man das auch nach Delphi übersetzen: PChar.

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
hathor
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Sa 08.09.07 17:21 
Memo1.lines.add(PChar(version));

geht leider auch nicht:
Ergebnis:

üÿÿ‹ð‰w‰~ ÇF¤B

statt: erste
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Sa 08.09.07 17:46 
Ich meinte in der Deklaration ... In nen String bekommste das ganze recht einfach mit StrPas.

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
hathor
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Sa 08.09.07 18:40 
version: PChar; //???

Memo1.lines.add(StrPas(version));

Ergebnis: Ö¡ˆF

Wir kommen der Sache schon näher - jetzt stimmt schon mal die Anzahl der Zeichen!
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Sa 08.09.07 21:39 
Kannst Du bitte mal die vollständige Deklaration des Datentyps in C und die Übersetzung in Delphi posten? incl. Aufruf-Konventionen und Parameter-Übergabe (der Delphi-Funktion (und C-Äquivalent).

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
hathor
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: So 09.09.07 16:21 
Weil ich keine Lösung gefunden habe, Strings auf "einfache" Art von einem C++-Programm über SHARED MEMORY zu DELPHI zu senden, packe ich jetzt die Strings in ein Array:

C++:
char bdata[128];

DELPHI:
bdata: array [0..127] of Char;
Da passen z.B. 8 Strings von 16 Zeichen oder 16 Strings von 8 Zeichen hinein.
Damit funktioniert es super - und mein Problem ist gelöst.

Vielen Dank allen, die sich den "Kopf zerbrochen" haben!