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

  • Home
  • SEARCH
  • 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 968859
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T02:33:04+00:00 2026-05-16T02:33:04+00:00

The application retrieve window handles, using Enum* routines. It happens that in the while

  • 0

The application retrieve window handles, using Enum* routines.

It happens that in the while the application manage the handle (get class name, window statistics…) of an enumerated/created window, the handle is no more valid. The code managing window handles are protected using a try/catch block, but the window handle is stored and the successively used for managing the represented window.

How to handle the window handle lifetime? It is possible to detect the handle invalidity?

I’d like to avoid try/catch blocks every time the application uses the window handles.

  • 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-16T02:33:04+00:00Added an answer on May 16, 2026 at 2:33 am

    I already have the actual solution… but I didn’t know about this until now!

    Thank you all for having clarified about the window handle lifetime, but there is actually a method for being detected about window handle lifetime: CbtProc.

    In the case the hook is installed system wide, it’s possible to notify specific applications (it depends all on real implementation of the CBT hook) about a window destroy, which indicates that the a specific handle won’t be valid after the notification.

    From the documentation:

    HCBT_DESTROYWND Specifies the handle to the window about to be destroyed.

    Of course the access of the handles using WINAPI routines must be synchronized with the notification system, which doesn’t seem to give good feasibility (CBT hook actually blocks window destroy because it is synchronized with the application logic).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing disk catalog application that requires me to get file icons using file
I developp a Java application using Windows Desktop Search from which I can retrieve
I have to write an application where I retrieve a lotto numbers that I
I am currently working on an application that will retrieve other users' locations based
I've inherited a C# window's application that I'm not real crazy about. I've got
I'm writing a C# application which needs to intercept Window Messages that another applications
Using a WebBrowser control in my Windows Forms application, I want to retrieve the
I am using WPF to write an Application. The Main window of the Application
I have an application that needs to retrieve a value out of a hidden
I am working on a windows application using c# . I want to retrieve

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.