Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6585869
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:43:05+00:00 2026-05-25T16:43:05+00:00

Is there a way to help convert a binary to a specified record in

  • 0

Is there a way to help convert a binary to a specified record in Delphi 5? And this binary is in little-endian.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T16:43:06+00:00Added an answer on May 25, 2026 at 4:43 pm

    Windows on Intel/AMD is little-endian too, so no endianness conversion is required.

    Now if you can show the specific record and where you get the binary data from, it will be easier to answer.

    You can read any kind of record from a file. If your record is declared thus that it has exactly the same layout as the binary data, you can read an entire record at once. If not, you’ll have to read each field separately.

    Generally, you can read records, or individual fields of a record, from a stream using

    var
      MyStream: TStream;
    ...
      MyStream := TFileStream.Create(Filename, options);
    ...
      MyStream.Read(variable, sizeof(variable));
    

    If your data comes from a TCP socket, you can, for instance, write it into a TMemoryStream, as bytes. Then you can reset the pointer of the stream to the beginning and read the data as shown.

    Update

    As David commented, if the bytes come over the TCP connection in network byte order, then it makes sense to run each field through one of the WinSock functions ntohs() or ntohl(), after all the above, but before the items in the record are used. ntohs() converts 2 byte types, while ntohl() converts 4 byte types. To send items, use the reverse functions htons() and htonl() on each item in the record before sending them (separately).

    FWIW, it is quite easy, in Win32, to change endianness using:

    // byte swaps 32 bit values
    function BSwap32(I: DWORD): DWORD; { inline; }
    asm
            BSWAP   EAX
    end;
    
    // byte swaps 16 bit values
    function BSwap16(I: WORD): WORD; { inline; }
    asm
            XCHG    AL,AH
    end;
    
    // byte swaps 64 bit values
    function BSwap64(I: QWORD): QWORD; { inline; }
    asm
            MOV     EDX,[EAX]
            MOV     EAX,[EAX+4]
            BSWAP   EAX
            BSWAP   EDX
    end;  
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there an easier way to convert Delphi 7 to Delphi 2009? or is
is there any way to convert this to a recursion form? how to find
Is there a way to change the context sensitive help in Visual Studio so
Is there any way to connect to RDC with help of smarphone? Can it
Is there a way or a library that can help me load assembly in
Is there a way to query a full text index to help determine additional
I know there has to be a way: I need help getting any hot
Is there way in next piece of code to only get the first record?
Is there a way I can convert an mp3 file into a wav/aiff in
is there a way to convert from unix timestamp to GMT in mysql while

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.