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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:06:12+00:00 2026-05-24T02:06:12+00:00

During the lifetime of a .NET process, does the handle of a System.Windows.Forms.Form ,

  • 0

During the lifetime of a .NET process, does the handle of a System.Windows.Forms.Form, lets say the main form used in Application.Run(form) actually change it’s value, i.e. if using the value of the handle in a different process, e.g. IntPtr handle = User32.FindWindow(null, "Name"), is there a case where that handle might be invalidated by the .NET runtime?

EDIT

I need to know the handles because I want to use SendMessage and WM_COPYDATA and the like for IPC.

  • 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-24T02:06:13+00:00Added an answer on May 24, 2026 at 2:06 am

    A window handle is guaranteed to be valid and not get reused for as long as the window lives. It’s index like in nature, valid globally and generally behaves more like a global ID than like a kernel handle(which are only valid in one process and pointer like in nature). Once the window gets closed the window handle might get reused and now points to another window.

    But what’s not obvious is if the lifetime of the Form and the underlying windows window are the same. I vaguely remember that in Delphi’s VCL(Which is the spiritual predecessor of Windows.Forms) certain property changes recreated the window in the background.

    The existence of the Control.RecreatingHandle property seems like a strong indication that indeed the lifetime of the underlying window can be shorter than the lifetime of the .net control. Which could lead to the handle of a Form changing during its lifetime.

    Control.RecreateHandle
    The RecreateHandle method is called whenever parameters are needed for a new control, but using a call from UpdateStyles to CreateParams is insufficient. This method also calls DestroyHandle and CreateHandle and sets RecreatingHandle to true.
    http://msdn.microsoft.com/en-us/library/system.windows.forms.control.recreatehandle.aspx

    From the description of this method I conclude that the window handle can indeed change during the lifetime of the form.

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

Sidebar

Related Questions

During an ASP.NET page load I'm opening and closing multiple System.Data.SqlClient.SqlConnections inside multiple controls
Application_Start and Application_End are called only once during the lifetime of the application domain
Where to dispose StreamWriter if I need it during entire application lifetime? I'm going
I have a UITableView that I am allocating multiple times during the lifetime of
During my apprenticeship, I have used NHibernate for some smaller projects which I mostly
In an ASP.NET application, we'd like to use the SqlWebEventProvider to log any Event
During the life of my web application I know all of my services and
I have written a custom template loader, and templates may change during the lifetime
When is the string literal "hello" allocated and deallocated during the lifetime of the
My application runs on a pSOS operating system. The code is compiled with Diab

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.