Autor Beitrag
kalle1
Hält's aus hier
Beiträge: 1



BeitragVerfasst: Do 31.05.07 09:49 
Ich bin dabei eine bestehendes System zu erweitern, welches bisher in C++ entwickelt wurde. Hierzu müsste ich von Delphi aus auf die von dem bisherigen C-Programm gespeicherten binary-Dateien zugreifen. Der C-Code zum öffnen der Datei "001" lautet:


ausblenden volle Höhe 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:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
// martin3.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"

#include <cstdlib>
#include <iostream>
#include <fstream>
#ifndef TtypesH
#define TtypesH
using namespace std;

int s;

int main(int argc, char* argv)
{   


// values are in Filename with ending ".001"
typedef struct MeasureHeader
{
  unsigned int MeasureCount;
  //unsigned char SystemCount;
  char          LackNr[5];
  char          Karosse[3];
  unsigned char Ort;
  char          FileNamePart[19];

} t_MeasureHeader;


// values are in Filename with ending ".001"
typedef struct TabMeasure
{
  unsigned int ID;
  double StartTime;
  double EndTime;
  double  Result;  // dE wert
  unsigned char Output;  // 1=IO 2=NIO 3=NoC
  unsigned char SysCount;
  __int64 StartPos_TabSystem[6]; // max. 6 Systeme d.h. 6 Kameras
} t_TabMeasure;



#endif



//----Daten ausgeben---------------------------------------------------------------------------

    ifstream file("001", ios::binary); 
    
  {if(!file) {cerr <<"Fehler beim Oeffnen der Datei \n"<< argv[1]
                      <<endl; system("PAUSE"); return 2;}}
      // Datei geladen


   t_TabMeasure col;
    
                   
   for (s = 0; s < 10; s++)  {  // Die ersten 10 Datensätze ausgeben
    
    file.read( ( char* )&col, sizeof(t_TabMeasure)); 
    
      cout << col.ID << " : " << col.StartTime  << " : " << col.EndTime; 
        printf("\n\n"); 
  
              }
          
        system("PAUSE");
     return 0;
}


Ist es möglich diese Datei auch direkt in Delphi auszulesen?
ich habe die zu öffnende Datei gepackt und angehängt.

Moderiert von user profile iconUGrohne: Beitragsformatierung überarbeitet.
Einloggen, um Attachments anzusehen!
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Do 31.05.07 09:54 
Es handelt sich hier ja um eine normale Struktur. Sollte eigentlich gut nach Delphi übertragbar sein. Ansonsten kannst du die Ladefunktion ja auch als c-Modul lassen.

_________________
Markus Kinzler.
Timosch
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 1314

Debian Squeeze, Win 7 Prof.
D7 Pers
BeitragVerfasst: Do 31.05.07 10:47 
user profile iconkalle1 hat folgendes geschrieben:
Ich bin dabei eine bestehendes System zu erweitern, welches bisher in C++ entwickelt wurde. Hierzu müsste ich von Delphi aus auf die von dem bisherigen C-Programm gespeicherten binary-Dateien zugreifen. Der C-Code zum öffnen der Datei "001" lautet:...

Bitte Quellcode-Tags benutzen.

_________________
If liberty means anything at all, it means the right to tell people what they do not want to hear. - George Orwell
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: Do 31.05.07 12:15 
Die Structs mit packed record übersetzen und die Char-Arrays mit Array [0..N-1] of char (und NICHT als String!!!).

Ansonsten eigentlich 1:1 übrtragbar ...

_________________
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.