473,786 Members | 2,660 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Why MainWindowHandl e is zero?

Question: why Process.MainWin dowHandle is zero?

--------------------------------------------------------------------------
From document of Process.MainWin dowHandle Property:

Property Value
The system-generated window handle of the main window of the associated
process.
Exceptions
Exception TypeCondition
InvalidOperatio nExceptionThe MainWindowHandl e is not defined because the
process has exited.
NotSupportedExc eptionYou are attempting to retrieve the MainWindowHandl e for
a process that is running on a remote computer.

Remarks
You can get the MainWindowHandl e property only for processes that are
running on the local computer. The MainWindowHandl e property is a value that
uniquely identifies the window that is associated with the process.
A process has a main window associated with it only if the process has a
graphical interface. If the associated process does not have a main window,
the MainWindowHandl e value is zero. If you have just started a process and
want to use its main window handle, consider using the WaitForInputIdl e
method to allow the process to finish starting, ensuring that the main
window handle has been created. Otherwise, an exception will be thrown.
--------------------------------------------------------------------------

I am trying to use GetProcessesByN ame("xxxx.exe") and then get the main
window's handle via Process.MainWin dowHandle; however, the return value is
zero.
1) the process is not in a remote computer;
2) the code works well if I change the process name to another one; e.g.
winmine.exe (the small game: mine sweeper :) )
3) the process xxxx.exe has finished starting. It is a kind of media player
and starts very fast. In fact, to testify that it has a main window handle,
I have tried to use Spy++ to find it and get its main window's handle and
title normally. Then I call SendMessage(hWn d, WM_GETTEXT, xxx, xxx) and get
its title.

1) Why I can NOT get the main window's handle via Process.MainWin dowHandle?
2) What you will do to accomplish this? I am trying EnumWindows()

Any response is highly appreciated. Thanks
Jul 21 '05 #1
0 3182

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

53
8221
by: Zhiqiang Ye | last post by:
Hi, All I am reading FAQ of this group. I have a question about this: http://www.eskimo.com/~scs/C-faq/q7.31.html It says: " p = malloc(m * n); memset(p, 0, m * n); The zero fill is all-bits-zero, and does not therefore guarantee useful null pointer values (see section 5 of this list) or floating-point zero values.
25
4438
by: pm940 | last post by:
Hello. I've been reading some past discussions on the NULL vs. zero. References are always made to systems or machienes that use values other than zero to represent the NULL pointer. Although not a practice I follow, there are no doubt millions of lines of open source libraries and applications that do things like: p = malloc(...);
2
4483
by: Moty Michaely | last post by:
Hello all, I am enumerating vb6 process from c# application by name. I need to send message to all processes that has the specified name but for this purpose I need the handle of the main window for each process returned. I once read that vb6 app mainWindowHandle is the handle of the hidden window that runs the application.
0
2623
by: Michiel | last post by:
Hello, When I execute the following code Process* oProc; IntPtr ipMain; HWND hWnd; oProc=Process::GetProcessById(m_IProcId); ipMain=oProc->MainWindowHandle; hWnd=(HWND)ipMain.ToPointer();
0
284
by: Luke | last post by:
Question: why Process.MainWindowHandle is zero? -------------------------------------------------------------------------- From document of Process.MainWindowHandle Property: Property Value The system-generated window handle of the main window of the associated process. Exceptions Exception TypeCondition
1
2529
by: codejunkie | last post by:
Hi, I am running a suite of tests of a WIN 32 application. Every test launches the same application, checks if the Application has a Main Window handle and then proceeds. However i am noticing when i run a reasonably large ( 80-90) number of tests one after the other the Main Window handle API displays inconsistant behavior. About 70% of the time my application returns a valid Main WIndow handle
4
7924
by: H.S. | last post by:
Hello, I am trying out a few methods with which to test of a given number is practically zero. as an example, does the following test correctly if a given number is zero within machine precision? I am trying out this method to check for a practical zero in an algorithm I am implementing in C++. ------------------------- #include <iostream> #include <iomanip>
23
4376
by: Hallvard B Furuseth | last post by:
As far as I can tell, (x & -1) is nonzero if the integer x is negative zero. So for signed types, x == 0 does not guarantee (x & foo) == 0. Is that right? (Not that I expect to ever encounter a non-two's-complement machine. Just wondering.) -- Hallvard
0
2198
by: siddharthkhare | last post by:
Hi all, I am trying to launch an process in .net as follows.I want to wait till mainwindow handle is initialized. fowlloing code works some times i.e i can read the value of mainwindow handle but some times it returns 0. I see the IE launched but still mainwindow handle is 0. I have pasted the code below. Question on waitforinputidle() A.Help on this method says "if process does not have a message queue,
0
9655
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9497
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10363
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10169
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8993
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7517
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5398
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5534
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.