Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi Type record of byte, word - schaffe es nicht (https://www.delphipraxis.net/148705-type-record-byte-word-schaffe-es-nicht.html)

schwa226 6. Mär 2010 22:17


Type record of byte, word - schaffe es nicht
 
Hi,

ich möchte diese Type von C auslesen:
Code:
typedef struct
{
  uint8_t              mytype;
  uint16_t             address;
  uint16_t             feature;
  uint8_t              flags;
} temp_DATA;
In Delphi also:
Delphi-Quellcode:
type
  TData = record
    mytype: UInt8;
    address: UInt16;
    feature: UInt16;
    flags: UInt8;
  end;
Per HidD_GetFeature lese ich dann die Daten.
Delphi-Quellcode:
  THidD_SetGetFeature = function (HidDeviceObject: THandle; var Report; Size : Integer):LongBool; stdcall;
So ist aber das Ergebnis, dass type verschluckt wird und die restlichen bytes nach vorn geschoben werden.

Wenn ich es so mache stimmt es:
Delphi-Quellcode:
type
  TData = record
    mytype: UInt8;
    address: Array[0..1] of UInt8;
    feature: Array[0..1] of UInt8;
    flags: UInt8;
  end;
Warum geht das nicht? :wiejetzt:

DeddyH 6. Mär 2010 22:55

Re: Type record of byte, word - schaffe es nicht
 
Hast Du es mal mit packed record versucht?

schwa226 6. Mär 2010 23:26

Re: Type record of byte, word - schaffe es nicht
 
Danke!

Mit "packed" geht's!
:cyclops:


Alle Zeitangaben in WEZ +1. Es ist jetzt 08:28 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz