![]() |
AW: einzelne bytes in ein 4-byte int umwandeln
Zitat:
Delphi-Quellcode:
sein, wobei in diesem Falle kein Padding und Aligning stattfinden sollte.
packed
|
AW: einzelne bytes in ein 4-byte int umwandeln
|
AW: einzelne bytes in ein 4-byte int umwandeln
das nennt man "Weitergabe des Wissens" und ist unsere Daseinsberechtigung.
Gruß K-H |
AW: einzelne bytes in ein 4-byte int umwandeln
Noch eine Lösung:
Delphi-Quellcode:
procedure TForm1.ButtonClick(Sender: TObject);
var aByte : Packed array[0..3] of Byte; dwErgebnis : DWord absolute aByte; begin //Einzelbyte eintragen aByte[0] :=$10; aByte[1] :=$20; aByte[2] :=$30; aByte[3] :=$40; //Ergebnis verwenden Label1.Caption:= IntToStr(dwErgebnis); end; |
AW: einzelne bytes in ein 4-byte int umwandeln
Zitat:
|
AW: einzelne bytes in ein 4-byte int umwandeln
Zitat:
Also zb:
Delphi-Quellcode:
danke :)
Int := $ABCDEF42;
byte1 := $AB; // get first byte from int byte2 := $CD; // get 2nd byte from int byte3 := $EF; // get 3rd byte from int byte4 := $42; // get 4th byte from int |
AW: einzelne bytes in ein 4-byte int umwandeln
Zitat:
Delphi-Quellcode:
byte1 := LongRec(Value).Bytes[0];
byte2 := LongRec(Value).Bytes[1]; byte3 := LongRec(Value).Bytes[2]; byte4 := LongRec(Value).Bytes[3]; |
AW: einzelne bytes in ein 4-byte int umwandeln
geil danke! da werden mir ja ganz neue seiten von delphi gezeit :D nur so aus interesse... gibts da auch ne möglichkeit mit shl und shr die nicht allzu komplex ist? :stupid:
|
AW: einzelne bytes in ein 4-byte int umwandeln
Zitat:
Delphi-Quellcode:
function GetByte(Index, Value: Integer): Byte;
var BitsToShift: Integer; begin BitsToShift := (Index xor 3) shl 3; result := (Value and ($FF shl BitsToShift)) shr BitsToShift; end; |
AW: einzelne bytes in ein 4-byte int umwandeln
Zitat:
Delphi-Quellcode:
B1 := DW and $FF;
B2 := (DW shr 8) and $FF; B3 := (DW shr 16) and $FF; B4 := (DW shr 24) and $FF; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 06:44 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz