Board index » cppbuilder » Using TStream and Structures
|
mike
CBuilder Developer |
Using TStream and Structures2007-04-04 05:12:01 AM cppbuilder97 Hello, could someone help me in reading data from a TStream into a structure. The following code is what I am trying to do. I have the following structure ( which represents a record type within an emf file ) typedef struct tagSPLHEADER { DWORD SIGNATURE; DWORD nSize; // record size INCLUDING header DWORD offDocumentName; // offset of Job Title from start DWORD offPort; // offset of portname from start BYTE HeaderData[]; } SPL_HEADER, *PSPL_HEADER; #define MAX_BUFFER 5000 // 5K of data at a time BYTE stbuffer[MAX_BUFFER]; So I am trying to read data from the file into this structure. The following gets my data into a buffer but now I do not know how to get the data into the structure. TFileStream *Filestrm = new TFileStream( "InputFile.spl", fmOpenRead | fmShareExclusive ) ; size = Filestrm->Read( stbuffer, sizeof ( SPL_HEADER ) ) ; So if I check stBuffer it has 16 bytes of data, but I would like to have this data in the structure defined above. Thank you for any help which may be provided. Mike |
