473,407 Members | 2,314 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Why MainWindowHandle is zero?

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
InvalidOperationExceptionThe MainWindowHandle is not defined because the
process has exited.
NotSupportedExceptionYou are attempting to retrieve the MainWindowHandle for
a process that is running on a remote computer.

Remarks
You can get the MainWindowHandle property only for processes that are
running on the local computer. The MainWindowHandle 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 MainWindowHandle value is zero. If you have just started a process and
want to use its main window handle, consider using the WaitForInputIdle
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 GetProcessesByName("xxxx.exe") and then get the main
window's handle via Process.MainWindowHandle; 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(hWnd, WM_GETTEXT, xxx, xxx) and get
its title.

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

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

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

Similar topics

53
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...
25
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...
2
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...
0
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
by: Luke | last post by:
Question: why Process.MainWindowHandle is zero? -------------------------------------------------------------------------- From document of Process.MainWindowHandle Property: Property Value...
1
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...
4
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...
23
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...
0
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.