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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:10:05+00:00 2026-05-17T00:10:05+00:00

Instance A is trying to restore instance B’s window, but I can’t get the

  • 0

Instance A is trying to restore instance B’s window, but I can’t get the B’s window handle. I think the problem is that the window is being minimized by B to the system tray using:

this.Visibility = Visibility.Hidden;

And A is trying to get B’s window handle using:

Process process = Process.GetCurrentProcess();
Process.GetProcessesByName(process.ProcessName).First().MainWindowHandle;

Which is equal to IntPtr.Zero.

I also tried to get the window handle by class name using Spy++ but the class name has a per-instance GUID in the following format:

HwndWrapper[FileName.exe;;ad445199-cf93-48a4-bd24-2f97d54c8af8]
  • 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-17T00:10:06+00:00Added an answer on May 17, 2026 at 12:10 am

    That is because what you want basically doesn’t exists, and the concept of MainWindowHandle is a gross misnomer that sneaked into the .Net Framework for everlasting confusion. From There can be more than one (or zero): Converting a process to a window:

    “I have a thread ID. How do I get the
    corresponding window?”

    You can use the EnumThreadWindows
    function to get all the windows on the
    thread.

    “Yes, I know about EnumThreadWindows,
    but how do I get the window that I
    want?”

    Well, you haven’t said what you wanted
    yet.

    “I want the window that corresponds to
    the thread.”

    But which one? How will you decide
    among all the windows?

    “That’s what I’m asking you!”

    But you haven’t yet described what you
    want.

    “I want the window corresponding to
    the thread. Why won’t you answer my
    question?”

    Note that saying, “I am looking for
    the top-level unowned window” is a
    step forward, but it still doesn’t
    uniquely identify a window. There can
    be multiple top-level unowned windows
    in a process. For example, Explorer
    typically has lots of top-level
    unowned windows. There’s the desktop,
    the taskbar, your open folder windows,
    and property sheets. If you ask for
    “the” top-level unowned window of
    Explorer, which one do you want?

    Perhaps people are getting the idea
    that there is a way to uniquely
    specify “the” window for a process
    because the System.Diagnostics.Process
    object has a property called
    MainWindowHandle. The documentation
    for that property doesn’t do anything
    to dispel the notion, either. I have
    no idea how that property decides
    among multiple top-level unowned
    windows.

    The topic is also elaborated in MSDN Q&A Get the Main Window:

    Q How can I find the main window for a process? I’m writing a Spy-like tool and I need to get the main window (HWND) for a process so I can send it a message like WM_ACTIVATEAPP.

    A Which main window do you mean?

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

Sidebar

Related Questions

I am trying to access the singleton instance created by my WCF service but
I'm trying to get the instance name of my class. The way I do
Trying to create an instance of a model, I get the following error... u
Trying to include a instance variable in a message that a UIAlertView Shows. lostAlert
I am trying to get the instance of a service class bound in jboss-service.xml
I'm trying to serialize an instance of the class Person: using System; using System.IO;
I'm trying to solve an instance of the weighted vertex cover problem using R
I'm trying to pass an instance of a class to another object, but i
I am trying to keep one instance of a Window around and when needed
I'm trying to an activemodel instance with translations. I find that the only way

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.