Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   Delphi Hex werte schreiben (https://www.delphipraxis.net/55161-hex-werte-schreiben.html)

Baeuerle 17. Okt 2005 15:15


Hex werte schreiben
 
Hallo,

kann mir jemand sagen wie ich einzelne Hexwerte in eine Datei schreiben kann?

z.b:
möchte ich folgende hexwerte schreiben

50 4B 05 06 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

fs.write($50,1) -> geht nicht!

Danke im vorraus
Baeuerle

Lernnix 17. Okt 2005 15:21

Re: Hex werte schreiben
 
Hallo Baeuerle!

Funktion IntToHex nehmen! Mit F1 zu diser Funktion findest Du die erforderliche Parameterliste.

Lernnix

Kroko1999 17. Okt 2005 15:21

Re: Hex werte schreiben
 
Delphi-Quellcode:
write (fs,'$'+IntToHex($50,2));

marabu 17. Okt 2005 15:39

Re: Hex werte schreiben
 
Vielleicht willst du eher das hier?

Delphi-Quellcode:
procedure WriteHex(fs: TFileStream; hex: string);
var
  buf: array of byte;
  i: integer;
begin
  SetLength(buf, Length(hex) shr 1);
  for i := Low(buf) to high(buf) do
    buf[i] := StrToInt('$' + Copy(hex, Succ(i shl 1), 2));
  fs.Write(buf[0], Length(buf));
end;

begin
  WriteHex(fs, '313233'); // schreibt '123'
end;
Grüße vom marabu

Baeuerle 17. Okt 2005 15:50

Re: Hex werte schreiben
 
THX @ marabu thats it :thumb:


Alle Zeitangaben in WEZ +1. Es ist jetzt 11:22 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