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 7857989
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T21:13:01+00:00 2026-06-02T21:13:01+00:00

I am using Indy9 with Delphi7. I would like to cast an Longword (Athread.Handle)

  • 0

I am using Indy9 with Delphi7.
I would like to cast an Longword (Athread.Handle) back to an TIDPEERTHREAD Pointer.
Is there a way how I could do this?
Or is there any other way I could “store” the Pointer to a Longword?

Thank you in Advance.

  • 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-06-02T21:13:07+00:00Added an answer on June 2, 2026 at 9:13 pm

    TIdPeerThread is a TThread descendant. Its Handle property contains the OS-level thread handle from CreateThread(). There is no way to cast a Handle value directly to a TIdPeerThread object pointer. You will have to either:

    1) Store the TIdPeerThread object pointer itself in the LongWord instead of the TIdPeerThread.Handle value, and then cast it back when needed:

    var
      LW: LongWord;
      Peer: TIdPeerThread;
    
    Peer := ...;
    LW := LongWord(Peer);
    ...
    Peer := TIdPeerThread(LW);
    

    2) Store the TIdPeerThead.Handle value in the LongWord, then loop through the TIdTCPServer.Threads list looking for a TIdPeerThread object that has a matching value when needed:

    var
      LW: LongWord;
      Peer: TIdPeerThread;
      List: TList;
      I: Integer;
    
    Peer := ...;
    LW := LongWord(Peer.Handle);
    ...
    Peer := nil; 
    List := IdTCPServer1.Threads.LockList;
    try
      for I := 0 to List.Count-1 do
      begin
        if LongWord(TIdPeerThread(List[I]).Handle) = LW then
        begin
          Peer := TIdPeerThread(List[I]);
          Break;
        end;
      end;
    finally
      IdTCPServer1.Threads.UnlockList;
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using a restful resource in Rails, I would like to be able to insert
Using Flex 3, I would like to take an image snapshot such as this:
I encoded a text in a TMemo using base64 encoding tools ( like Indy
I'm trying to resume an upload using indy (HTTP Post), the code looks like
I would like to add roots to a VirtualTreeView http://www.delphi-gems.com/index.php/controls/virtual-treeview with a thread like
I am trying to send an e-mail using gmail account (Delphi 7, Indy 10)
I am using indy's http server for a project so i have a few
I'm using the IdFTP (Indy 10) component to download some files (zip and txt)
I'm using the latest indy snapshot (installed yesterday) and newest SSL libraries. When trying
Using LINQ on collections, what is the difference between the following lines of code?

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.